i have function for combine number like this
function combin($mainArray, $size, $combinations = [])
{
if (empty($combinations)): $combinations = $mainArray; endif;
if ($size == 1): return str_replace('-','',$combinations); endif;
$newCombination = array();
foreach ($mainArray as $key => $val):
foreach ($combinations as $char):
if(in_array($val, explode('-', $char))): continue; endif;
$newCombination[] = $val . '-' . $char;
endforeach;
endforeach;
return combin($mainArray, $size - 1, $newCombination);
}
$num = '1111111111';
$num = str_split($num);
//--//
echo '<pre>';
print_r(combin($num,4));
echo '</pre>';
i have problem when i input number like this 1111111111
the result is like this and this result i wrong
Array
(
[0] => 1
[1] => 1
[2] => 1
[3] => 1
[4] => 1
[5] => 1
[6] => 1
[7] => 1
[8] => 1
[9] => 1
)
what i want the result is like this and this is the correct result
Array
(
[0] => 1111
)
i hope someone can help me