Php
$cats = array( "P1"=>array( "C1"=>array( "C11"=>array(), "C12"=>array( "C121"=>array() ) ) ), "P2"=>array( "D1"=>array( "D11"=>array( "D121"=>array(), "D122"=>array( "D1221"=>array() ) ), "D12"=>array() ) ), "P3"=>array() ); a. Get deepest child of each parent Expected Output: Deepest child of each parent. P1 => C121 P2 => D1221 P3 => b. Get path for each element in the array Expected output: Path for each element Array ( [P1] => P1 [C1] => P1->C1 [C11] => P1->C1->C11 [C12] => P1->C1->C12 [C121] => P1->C1->C12->C121 [P2] => P2 [D1] => P2->D1 [D11] => P2->D1->D11 [D121] => P2->D1->D11->D121 [D122] => P2->D1->D11->D122 [D1221] => P2->D1->D11->D122->D1221 [D12] => P2->D1->D12 [P3] => P3 ) 1m 33s