3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array(array('id' => '10', 'name' => 'aaa', 'nodes' =>array()), array('id' => '11', 'name' => 'bbb','nodes' =>array('id' => '21', 'name' => 'aaaaaa','nodes'=> array("11"=>"haha"))), array('id' => '12', 'name' => 'ccc', 'nodes' =>array()), array('id' => '13', 'name' => 'ddd', 'nodes' =>array('id' => '23', 'name' => 'cccccc','nodes'=> array())), array('id' => '14', 'name' => 'eee', 'nodes' =>array()) ); function FormatTagString($num){ $tag = "-"; $string=""; for ($i=0;$i<$num;$i++){ $string.=$tag; } return $string; } function GetTree($array,$level){ global $tree; foreach ($array as $k=>$v){ if (!is_array($v))$tree.=FormatTagString($level).$v."<br />"; else GetTree($v,$level+1); } return $tree; } $string = GetTree($array,1); print_r($string);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mkDQd
function name:  (null)
number of ops:  10
compiled vars:  !0 = $array, !1 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   26     1        INIT_FCALL                                               'gettree'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 1
          4        DO_FCALL                                      0  $3      
          5        ASSIGN                                                   !1, $3
   27     6        INIT_FCALL                                               'print_r'
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                                 
          9      > RETURN                                                   1

Function formattagstring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 9, Position 2 = 5
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 9, Position 2 = 5
Branch analysis from position: 9
Branch analysis from position: 5
filename:       /in/mkDQd
function name:  FormatTagString
number of ops:  11
compiled vars:  !0 = $num, !1 = $tag, !2 = $string, !3 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
    9     1        ASSIGN                                                   !1, '-'
   10     2        ASSIGN                                                   !2, ''
   11     3        ASSIGN                                                   !3, 0
          4      > JMP                                                      ->7
   12     5    >   ASSIGN_OP                                     8          !2, !1
   11     6        PRE_INC                                                  !3
          7    >   IS_SMALLER                                               !3, !0
          8      > JMPNZ                                                    ~9, ->5
   14     9    > > RETURN                                                   !2
   15    10*     > RETURN                                                   null

End of function formattagstring

Function gettree:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 22
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 22
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 16
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
filename:       /in/mkDQd
function name:  GetTree
number of ops:  25
compiled vars:  !0 = $array, !1 = $level, !2 = $tree, !3 = $v, !4 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   18     2        BIND_GLOBAL                                              !2, 'tree'
   19     3      > FE_RESET_R                                       $5      !0, ->22
          4    > > FE_FETCH_R                                       ~6      $5, !3, ->22
          5    >   ASSIGN                                                   !4, ~6
   20     6        TYPE_CHECK                                  128  ~8      !3
          7        BOOL_NOT                                         ~9      ~8
          8      > JMPZ                                                     ~9, ->16
          9    >   INIT_FCALL                                               'formattagstring'
         10        SEND_VAR                                                 !1
         11        DO_FCALL                                      0  $10     
         12        CONCAT                                           ~11     $10, !3
         13        CONCAT                                           ~12     ~11, '%3Cbr+%2F%3E'
         14        ASSIGN_OP                                     8          !2, ~12
         15      > JMP                                                      ->21
   21    16    >   INIT_FCALL_BY_NAME                                       'GetTree'
         17        SEND_VAR_EX                                              !3
         18        ADD                                              ~14     !1, 1
         19        SEND_VAL_EX                                              ~14
         20        DO_FCALL                                      0          
   19    21    > > JMP                                                      ->4
         22    >   FE_FREE                                                  $5
   23    23      > RETURN                                                   !2
   24    24*     > RETURN                                                   null

End of function gettree

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.68 ms | 1403 KiB | 17 Q