<?php $a = Array( Array(1,2,3), Array(4,5,6), Array(7,8,9) ); function find_paths($array) { if (count($array) == 1) return $array[0]; $output = array(); foreach (array_shift($array) as $v1) { foreach (find_paths($array) as $v2) { $output[] = array_merge(array($v1), is_array($v2) ? $v2 : array($v2)); } } return $output; } $combinations = find_paths($a); print_r($combinations); $sums = array_map(function ($v) { return array_sum($v);}, $combinations); print_r($sums);
You have javascript disabled. You will not be able to edit any code.
Value for `_results` contains invalid data `array`