php numbers are recursively combined and arranged:
$a="123,45,6789,...";//There is no limit to the number of digits in each segment. If it is a 4-segment number, the resulting combination will be 4 digits, and so on.
Need to get the combined array:
6,4,1
6,4,2
6,4,3
6,5,1
6,5,2
6,5,3
7,4,1
7 ,4,2
7,4,3
7,5,1
7,5,2
7,5,3
8,4,1
8,4,2
8,4,3
8,5 ,1
...
Looking for php recursive function
php numbers are recursively combined and arranged:
$a="123,45,6789,...";//There is no limit to the number of digits in each segment. If it is a 4-segment number, the resulting combination will be 4 digits, and so on.
Need to get the combined array:
6,4,1
6,4,2
6,4,3
6,5,1
6,5,2
6,5,3
7,4,1
7 ,4,2
7,4,3
7,5,1
7,5,2
7,5,3
8,4,1
8,4,2
8,4,3
8,5 ,1
...
Looking for php recursive function
<code>function recursion($groups, $echo = '') { $current = array_pop($groups); $end = empty($groups); $echo .= $echo ? ',' : ''; foreach (str_split($current) as $item) { $rEcho = $echo . $item; if ($end) { echo $rEcho . "\n"; } else { recursion($groups, $rEcho); } } } recursion(explode(',', '123,45,6789'));</code>