3v4l.org

run code in 300+ PHP versions simultaneously
<?php function loop($array) { echo '<ol class="dd-list">'; echo "\n"; $arrayObj = new ArrayObject($array); foreach ( $iterator = $arrayObj->getIterator() as $key => $value ) { if(is_array($iterator->current())) { loop($iterator->current()); } else { if($iterator->key()=='position') { echo '<li class="dd-item" data-id="' . $iterator->current() . '">'; echo '<div class="dd-handle">' . $iterator->key() . ' ' . $iterator->current() . '</div>'; echo '</li>'; echo "\n"; } } } echo '</ol>'; } $testArray = array('1', '2', array('3', '4')); /* $arrayObj = new ArrayObject($testArray); foreach ( $iterator = $arrayObj->getIterator() as $key => $value ) { echo 'key ' . $iterator->key(); echo "\n"; echo 'current' . $iterator->current(); echo "\n"; echo "\n"; } */ loop($testArray);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/v8IW8
function name:  (null)
number of ops:  5
compiled vars:  !0 = $testArray
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   ASSIGN                                                   !0, <array>
   33     1        INIT_FCALL                                               'loop'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0          
          4      > RETURN                                                   1

Function loop:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 44
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 44
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 23
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 43
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 43
Branch analysis from position: 44
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 44
filename:       /in/v8IW8
function name:  loop
number of ops:  47
compiled vars:  !0 = $array, !1 = $arrayObj, !2 = $iterator, !3 = $value, !4 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        ECHO                                                     '%3Col+class%3D%22dd-list%22%3E'
    5     2        ECHO                                                     '%0A'
    6     3        NEW                                              $5      'ArrayObject'
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !1, $5
    7     7        INIT_METHOD_CALL                                         !1, 'getIterator'
          8        DO_FCALL                                      0  $8      
          9        ASSIGN                                           ~9      !2, $8
         10      > FE_RESET_R                                       $10     ~9, ->44
         11    > > FE_FETCH_R                                       ~11     $10, !3, ->44
         12    >   ASSIGN                                                   !4, ~11
    8    13        INIT_METHOD_CALL                                         !2, 'current'
         14        DO_FCALL                                      0  $13     
         15        TYPE_CHECK                                  128          $13
         16      > JMPZ                                                     ~14, ->23
    9    17    >   INIT_FCALL_BY_NAME                                       'loop'
         18        INIT_METHOD_CALL                                         !2, 'current'
         19        DO_FCALL                                      0  $15     
         20        SEND_VAR_NO_REF_EX                                       $15
         21        DO_FCALL                                      0          
         22      > JMP                                                      ->43
   11    23    >   INIT_METHOD_CALL                                         !2, 'key'
         24        DO_FCALL                                      0  $17     
         25        IS_EQUAL                                                 $17, 'position'
         26      > JMPZ                                                     ~18, ->43
   12    27    >   INIT_METHOD_CALL                                         !2, 'current'
         28        DO_FCALL                                      0  $19     
         29        CONCAT                                           ~20     '%3Cli+class%3D%22dd-item%22+data-id%3D%22', $19
         30        CONCAT                                           ~21     ~20, '%22%3E'
         31        ECHO                                                     ~21
   13    32        INIT_METHOD_CALL                                         !2, 'key'
         33        DO_FCALL                                      0  $22     
         34        CONCAT                                           ~23     '%3Cdiv+class%3D%22dd-handle%22%3E', $22
         35        CONCAT                                           ~24     ~23, '++'
         36        INIT_METHOD_CALL                                         !2, 'current'
         37        DO_FCALL                                      0  $25     
         38        CONCAT                                           ~26     ~24, $25
         39        CONCAT                                           ~27     ~26, '%3C%2Fdiv%3E'
         40        ECHO                                                     ~27
   14    41        ECHO                                                     '%3C%2Fli%3E'
   15    42        ECHO                                                     '%0A'
    7    43    > > JMP                                                      ->11
         44    >   FE_FREE                                                  $10
   19    45        ECHO                                                     '%3C%2Fol%3E'
   20    46      > RETURN                                                   null

End of function loop

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
166.34 ms | 1407 KiB | 14 Q