- array_values: documentation ( source)
- str_split: documentation ( source)
<?php
function findFamily($n) {
$numbers = str_split("$n");
$combos = array();
$count = count($numbers);
for($i = 0; $i < $count; $i++) {
$baseNumber = $numbers[$i];
echo $i."\n";
$tempArray = $numbers;
unset($tempArray[$i]);
$tempArray = array_values($tempArray);
$countTempArray = count($tempArray);
for($i = 0; $i < $countTempArray; $i++) {
$combos[] = $baseNumber.$tempArray[$i].$tempArray[$i + 1];
$value = $tempArray[$i];
unset($tempArray[$i]);
$tempArray[] = $value;
}
}
return $combos;
}
FindFamily(123);