3v4l.org

run code in 300+ PHP versions simultaneously
<?php function loop($array) { echo '<ol class="dd-list">'; $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 '</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/TXVCq
function name:  (null)
number of ops:  5
compiled vars:  !0 = $testArray
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   ASSIGN                                                   !0, <array>
   31     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 = 10, Position 2 = 42
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 42
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 22
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 41
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 41
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 42
filename:       /in/TXVCq
function name:  loop
number of ops:  45
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        NEW                                              $5      'ArrayObject'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $5
    6     6        INIT_METHOD_CALL                                         !1, 'getIterator'
          7        DO_FCALL                                      0  $8      
          8        ASSIGN                                           ~9      !2, $8
          9      > FE_RESET_R                                       $10     ~9, ->42
         10    > > FE_FETCH_R                                       ~11     $10, !3, ->42
         11    >   ASSIGN                                                   !4, ~11
    7    12        INIT_METHOD_CALL                                         !2, 'current'
         13        DO_FCALL                                      0  $13     
         14        TYPE_CHECK                                  128          $13
         15      > JMPZ                                                     ~14, ->22
    8    16    >   INIT_FCALL_BY_NAME                                       'loop'
         17        INIT_METHOD_CALL                                         !2, 'current'
         18        DO_FCALL                                      0  $15     
         19        SEND_VAR_NO_REF_EX                                       $15
         20        DO_FCALL                                      0          
         21      > JMP                                                      ->41
   10    22    >   INIT_METHOD_CALL                                         !2, 'key'
         23        DO_FCALL                                      0  $17     
         24        IS_EQUAL                                                 $17, 'position'
         25      > JMPZ                                                     ~18, ->41
   11    26    >   INIT_METHOD_CALL                                         !2, 'current'
         27        DO_FCALL                                      0  $19     
         28        CONCAT                                           ~20     '%3Cli+class%3D%22dd-item%22+data-id%3D%22', $19
         29        CONCAT                                           ~21     ~20, '%22%3E'
         30        ECHO                                                     ~21
   12    31        INIT_METHOD_CALL                                         !2, 'key'
         32        DO_FCALL                                      0  $22     
         33        CONCAT                                           ~23     '%3Cdiv+class%3D%22dd-handle%22%3E', $22
         34        CONCAT                                           ~24     ~23, '++'
         35        INIT_METHOD_CALL                                         !2, 'current'
         36        DO_FCALL                                      0  $25     
         37        CONCAT                                           ~26     ~24, $25
         38        CONCAT                                           ~27     ~26, '%3C%2Fdiv%3E'
         39        ECHO                                                     ~27
   13    40        ECHO                                                     '%3C%2Fli%3E'
    6    41    > > JMP                                                      ->10
         42    >   FE_FREE                                                  $10
   17    43        ECHO                                                     '%3C%2Fol%3E'
   18    44      > RETURN                                                   null

End of function loop

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.91 ms | 1403 KiB | 14 Q