get path of Array (PHP)
- by Kawah Grafis
i have an array input like this ..
Array
(
[0] => Array
(
[0] => 42
)
[**42**] => Array
(
[0] => 12
[1] => 14
)
[**14**] => Array
(
[0] => 317
)
[317] => Array
(
[0] => 319
)
[**12**] => Array
(
[0] => 306
[1] => 307
)
[307] => Array
(
[0] => 311
)
[306] => Array
(
[0] => 309
)
)
and i want to get result array like bellow :
$paths[]=array(42,12,306,309);
$paths[]=array(42,12,307,311);
$paths[]=array(42,14,317,319);
see array input
root in array input = 42 (index of array 0)
42 have child = 12, 14
12 have child = 306, 307
14 have child = 317
306 have child = 309
307 have child = 311
317 have child = 319
like this..
and output array insert into $paths
$paths[0]=array(42,12,306,309);
$paths[1]=array(42,12,307,311);
$paths[2]=array(42,14,317,319);