<?
$a = array(1,2,3,4);
$dizi = array();
for ( $t = 1; $t <=count($a); $t++ )
{
$dizi[$t] = kombine ( $a, $t);
}
function kombine ( $a, $t )
{
global $dizi;
if ( $t == 1 ) return $a;
$temp = array();
foreach ( $dizi[$t-1] as $k=>$c )
{
foreach ( $a as $k1=>$c1 )
{
if ( strpos ( $c , "," ) !== FALSE )
$cx = explode( ",", $c);
if ( is_array ( @$cx ) )
if ( !in_array($c1, $cx) )
{
$temp[] = $c . "," . $c1;
continue;
}
if ( !is_array ( @$cx ) )
if ( $c!=$c1)
$temp[] = $c . "," . $c1;
}
}
return $temp;
}
print_r ( $dizi );
?>
C:\php>php h.php
Array
(
[1] => Array
(
[0] => 1
[1] => 2
[2] => 3
[3] => 4
)
[2] => Array
(
[0] => 1,2
[1] => 1,3
[2] => 1,4
[3] => 2,1
[4] => 2,3
[5] => 2,4
[6] => 3,1
[7] => 3,2
[8] => 3,4
[9] => 4,1
[10] => 4,2
[11] => 4,3
)
[3] => Array
(
[0] => 1,2,3
[1] => 1,2,4
[2] => 1,3,2
[3] => 1,3,4
[4] => 1,4,2
[5] => 1,4,3
[6] => 2,1,3
[7] => 2,1,4
[8] => 2,3,1
[9] => 2,3,4
[10] => 2,4,1
[11] => 2,4,3
[12] => 3,1,2
[13] => 3,1,4
[14] => 3,2,1
[15] => 3,2,4
[16] => 3,4,1
[17] => 3,4,2
[18] => 4,1,2
[19] => 4,1,3
[20] => 4,2,1
[21] => 4,2,3
[22] => 4,3,1
[23] => 4,3,2
)
[4] => Array
(
[0] => 1,2,3,4
[1] => 1,2,4,3
[2] => 1,3,2,4
[3] => 1,3,4,2
[4] => 1,4,2,3
[5] => 1,4,3,2
[6] => 2,1,3,4
[7] => 2,1,4,3
[8] => 2,3,1,4
[9] => 2,3,4,1
[10] => 2,4,1,3
[11] => 2,4,3,1
[12] => 3,1,2,4
[13] => 3,1,4,2
[14] => 3,2,1,4
[15] => 3,2,4,1
[16] => 3,4,1,2
[17] => 3,4,2,1
[18] => 4,1,2,3
[19] => 4,1,3,2
[20] => 4,2,1,3
[21] => 4,2,3,1
[22] => 4,3,1,2
[23] => 4,3,2,1
)
)
C:\php>