I want to find the max path through a multidimensional array. It is set up like a tree structure.
EDIT: I guess what I am looking for is how to find a Maximum Spanning for an array.
$tree = [
0 => '45',
1 => [
0 => [
0 => '3',
1 => [
0 => [0 => '88'],
],
],
1 => [
0 => '2',
1 => [
0 => [ 0 => '77'],
],
],
2 => [
0 => '5',
1 => [
0 => [
0 => '67',
1 => [
0 => [
0 => '2',
1 => [
0 => [ 0 => '35' ],
],
],
1 => [
0 => '3',
1 => [
0 => [ 0 => '44' ],
],
],
],
],
],
],
],
];
What I want to do is feed this into a function and get back
1. Every unique set of paths like
45, 3, 88 = 136
45, 2, 77 = 124
45, 5, 67, 2, 35 = 154
45, 5, 67, 3, 44 = 164
2. Or the max path, just the highest of those.
164
I generate these trees from some pretty random data so they are sometimes 10s or hundreds of tiers and 100s or 1000s of unique paths.