3v4l.org

run code in 300+ PHP versions simultaneously
<?php $source=json_decode('[{"name":"item 1"},{"name":"item 2"},{"name":"item 3","children":[{"name":"item 4"},{"name":"item 5"},{"name":"item 6","children":[{"name":"item 7"},{"name":"item 8"}]}]},{"name":"item 9"},{"name":"item 10"},{"name":"item 11"}]',true); function buildNestedList(array $a) { if(empty($a["name"])) { echo "\n<ol>\n"; foreach($a as $item) { buildNestedList($item); } echo "</ol>\n"; } else { echo "\t<li><div>".$a["name"]."</div>"; if(!empty($a["children"])) { buildNestedList($a["children"]); } echo "</li>\n"; } } buildNestedList($source);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/trFpp
function name:  (null)
number of ops:  9
compiled vars:  !0 = $source
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                               'json_decode'
          1        SEND_VAL                                                 '%5B%7B%22name%22%3A%22item+1%22%7D%2C%7B%22name%22%3A%22item+2%22%7D%2C%7B%22name%22%3A%22item+3%22%2C%22children%22%3A%5B%7B%22name%22%3A%22item+4%22%7D%2C%7B%22name%22%3A%22item+5%22%7D%2C%7B%22name%22%3A%22item+6%22%2C%22children%22%3A%5B%7B%22name%22%3A%22item+7%22%7D%2C%7B%22name%22%3A%22item+8%22%7D%5D%7D%5D%7D%2C%7B%22name%22%3A%22item+9%22%7D%2C%7B%22name%22%3A%22item+10%22%7D%2C%7B%22name%22%3A%22item+11%22%7D%5D'
          2        SEND_VAL                                                 <true>
          3        DO_ICALL                                         $1      
          4        ASSIGN                                                   !0, $1
   25     5        INIT_FCALL                                               'buildnestedlist'
          6        SEND_VAR                                                 !0
          7        DO_FCALL                                      0          
          8      > RETURN                                                   1

Function buildnestedlist:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 13
Branch analysis from position: 3
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 10
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 10
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 25
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
filename:       /in/trFpp
function name:  buildNestedList
number of ops:  27
compiled vars:  !0 = $a, !1 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    6     1        ISSET_ISEMPTY_DIM_OBJ                         1          !0, 'name'
          2      > JMPZ                                                     ~2, ->13
    8     3    >   ECHO                                                     '%0A%3Col%3E%0A'
    9     4      > FE_RESET_R                                       $3      !0, ->10
          5    > > FE_FETCH_R                                               $3, !1, ->10
   11     6    >   INIT_FCALL_BY_NAME                                       'buildNestedList'
          7        SEND_VAR_EX                                              !1
          8        DO_FCALL                                      0          
    9     9      > JMP                                                      ->5
         10    >   FE_FREE                                                  $3
   13    11        ECHO                                                     '%3C%2Fol%3E%0A'
         12      > JMP                                                      ->26
   17    13    >   FETCH_DIM_R                                      ~5      !0, 'name'
         14        CONCAT                                           ~6      '%09%3Cli%3E%3Cdiv%3E', ~5
         15        CONCAT                                           ~7      ~6, '%3C%2Fdiv%3E'
         16        ECHO                                                     ~7
   18    17        ISSET_ISEMPTY_DIM_OBJ                         1  ~8      !0, 'children'
         18        BOOL_NOT                                         ~9      ~8
         19      > JMPZ                                                     ~9, ->25
   20    20    >   INIT_FCALL_BY_NAME                                       'buildNestedList'
         21        CHECK_FUNC_ARG                                           
         22        FETCH_DIM_FUNC_ARG                               $10     !0, 'children'
         23        SEND_FUNC_ARG                                            $10
         24        DO_FCALL                                      0          
   22    25    >   ECHO                                                     '%3C%2Fli%3E%0A'
   24    26    > > RETURN                                                   null

End of function buildnestedlist

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.86 ms | 1402 KiB | 16 Q