3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array( 0 => array( "text" => "eventyrer", "children"=> array( 4 => array( "text" => "news", "children"=> array( 1=> array("text"=>"a") ) ), 5 => array( "text" => "nyheter", "children"=> array( 1=> array("text"=>"b") ) ) ) ), 1 => array( "text" => "eventyrer2017", "children"=> array( 6 => array( "text" => "news", "children"=> array( 1=> array("text"=>"c") ) ), 8 => array( "text" => "nyheter", "children"=> array( 1=> array( "text"=>"d", "children"=> array( 1=> array("text"=>"e") ) ) ) ) ) ) ); $new_array = []; foreach($arr as &$value) { //loop through first set foreach($value['children'] as $child) { //loop through children, create a string that contains the first set of values "text", and the childrens "text" $string = "{$value['text']}/{$child['text']}"; foreach($child['children'] as $child2) { //loop through each child of child1 and add a new string to the new_array containing `$string` + the child2. $new_array[] = $string .= "/{$child2['text']}"; } } } var_export($new_array);
Output for git.master_jit, git.master, rfc.property-hooks
array ( 0 => 'eventyrer/news/a', 1 => 'eventyrer/nyheter/b', 2 => 'eventyrer2017/news/c', 3 => 'eventyrer2017/nyheter/d', )

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
41.76 ms | 401 KiB | 8 Q