3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $myArray = Array ( Array ( 'id' => 6, 'title' => 'zzz', 'parentID' => 0, 'parentName' =>'', 'section' => 'articles', 'sort' => 0, 'level' => 0 ), Array ( Array ( 'id' => 7, 'title' => 7, 'parentID' => 6, 'parentName' => '', 'section' => 'articles', 'sort' => 0, 'level' => 0 ), Array ( Array ( 'id' => 8, 'title' => 8, 'parentID' => 7, 'parentName' =>'' , 'section' => 'articles', 'sort' => 0, 'level' => 0 ) ) ), Array ( 'id' => 1, 'title' => '?a?3?a', 'parentID' => 0, 'parentName' => '', 'section' => 'articles', 'sort' => 0, 'level' => 0 ), Array ( Array ( 'id' => 4, 'title' => 4, 'parentID' => 1, 'parentName' => '', 'section' => 'articles', 'sort' => 0, 'level' => 0 ), Array ( 'id' => 5, 'title' => 5, 'parentID' => 1, 'parentName' => '', 'section' => 'articles', 'sort' => 0, 'level' => 0 ) ) ); function arrayStack( $array, $dash ){ foreach($array as $value){ if(isset($value['id'])){ echo str_repeat("-", $dash).$value['id'].'<br/>'; }else{ $dash++; arrayStack( $value, $dash ); $dash--; } } } arrayStack( $myArray, 0 );
Output for 4.3.0 - 7.1.0
6<br/>-7<br/>--8<br/>1<br/>-4<br/>-5<br/>