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);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 3, Position 2 = 27
Branch analysis from position: 3
2 jumps found. (Code = 126) Position 1 = 4, Position 2 = 27
Branch analysis from position: 4
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 25
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 25
Branch analysis from position: 7
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 23
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 23
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 23
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 25
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
filename:       /in/rOidO
function name:  (null)
number of ops:  32
compiled vars:  !0 = $arr, !1 = $new_array, !2 = $value, !3 = $child, !4 = $string, !5 = $child2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   48     1        ASSIGN                                                   !1, <array>
   50     2      > FE_RESET_RW                                      $8      !0, ->27
          3    > > FE_FETCH_RW                                              $8, !2, ->27
   53     4    >   FETCH_DIM_R                                      ~9      !2, 'children'
          5      > FE_RESET_R                                       $10     ~9, ->25
          6    > > FE_FETCH_R                                               $10, !3, ->25
   56     7    >   FETCH_DIM_R                                      ~11     !2, 'text'
          8        ROPE_INIT                                     3  ~14     ~11
          9        ROPE_ADD                                      1  ~14     ~14, '%2F'
         10        FETCH_DIM_R                                      ~12     !3, 'text'
         11        ROPE_END                                      2  ~13     ~14, ~12
         12        ASSIGN                                                   !4, ~13
   58    13        FETCH_DIM_R                                      ~17     !3, 'children'
         14      > FE_RESET_R                                       $18     ~17, ->23
         15    > > FE_FETCH_R                                               $18, !5, ->23
   61    16    >   NOP                                                      
         17        FETCH_DIM_R                                      ~20     !5, 'text'
         18        FAST_CONCAT                                      ~21     '%2F', ~20
         19        ASSIGN_OP                                     8  ~22     !4, ~21
         20        ASSIGN_DIM                                               !1
         21        OP_DATA                                                  ~22
   58    22      > JMP                                                      ->15
         23    >   FE_FREE                                                  $18
   53    24      > JMP                                                      ->6
         25    >   FE_FREE                                                  $10
   50    26      > JMP                                                      ->3
         27    >   FE_FREE                                                  $8
   67    28        INIT_FCALL                                               'var_export'
         29        SEND_VAR                                                 !1
         30        DO_ICALL                                                 
         31      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.98 ms | 1400 KiB | 15 Q