3v4l.org

run code in 300+ PHP versions simultaneously
<?php // extend the RecursiveIteratorIterator class ULRows extends RecursiveIteratorIterator { function __construct($it) { // here we use the parent class and use LEAVES_ONLY to parent::__construct($it, self::LEAVES_ONLY); } function beginChildren() { echo '<ul>'; } function endChildren() { echo '</ul>' . "\n"; } } /** * * an array of animal ** */ $animals = array( array('type' => 'dog','name' => 'butch','sex' => 'm','breed' => 'boxer'), array('type' => 'dog','name' => 'fido','sex' => 'm','breed' => 'doberman'), array('type' => 'dog','name' => 'girly','sex' => 'f','breed' => 'poodle'), array('type' => 'cat','name' => 'tiddles','sex' => 'm','breed' => 'ragdoll'), array('type' => 'cat','name' => 'tiddles','sex' => 'f','breed' => 'manx'), array('type' => 'cat','name' => 'tiddles','sex' => 'm','breed' => 'maine coon'), array('type' => 'horse','name' => 'ed','sex' => 'm','breed' => 'clydesdale'), array('type' => 'perl_coder','name' => 'shadda','sex' => 'none','breed' => 'mongrel'), array('type' => 'duck','name' => 'galapogus','sex' => 'm','breed' => 'pekin')); /** * * create a new recursive array iterator ** */ $iterator = new RecursiveIteratorIterator(new RecursiveArrayIterator(new ArrayIterator($animals))); /** * * traverse the $iterator object ** */ while ( $iterator->valid() ) { var_dump($iterator->current()); echo "<li>" . $iterator->current() . '</li>'; $iterator->next(); } ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
2 jumps found. (Code = 44) Position 1 = 27, Position 2 = 12
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 27, Position 2 = 12
Branch analysis from position: 27
Branch analysis from position: 12
filename:       /in/jj1Rh
function name:  (null)
number of ops:  28
compiled vars:  !0 = $animals, !1 = $iterator
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   ASSIGN                                                   !0, <array>
   37     1        NEW                                              $3      'RecursiveIteratorIterator'
          2        NEW                                              $4      'RecursiveArrayIterator'
          3        NEW                                              $5      'ArrayIterator'
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0          
          6        SEND_VAR_NO_REF_EX                                       $5
          7        DO_FCALL                                      0          
          8        SEND_VAR_NO_REF_EX                                       $4
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !1, $3
   41    11      > JMP                                                      ->24
   43    12    >   INIT_FCALL                                               'var_dump'
         13        INIT_METHOD_CALL                                         !1, 'current'
         14        DO_FCALL                                      0  $10     
         15        SEND_VAR                                                 $10
         16        DO_ICALL                                                 
   44    17        INIT_METHOD_CALL                                         !1, 'current'
         18        DO_FCALL                                      0  $12     
         19        CONCAT                                           ~13     '%3Cli%3E', $12
         20        CONCAT                                           ~14     ~13, '%3C%2Fli%3E'
         21        ECHO                                                     ~14
   45    22        INIT_METHOD_CALL                                         !1, 'next'
         23        DO_FCALL                                      0          
   41    24    >   INIT_METHOD_CALL                                         !1, 'valid'
         25        DO_FCALL                                      0  $16     
         26      > JMPNZ                                                    $16, ->12
   47    27    > > RETURN                                                   1

Class ULRows:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jj1Rh
function name:  __construct
number of ops:  7
compiled vars:  !0 = $it
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    8     1        INIT_STATIC_METHOD_CALL                                  
          2        SEND_VAR_EX                                              !0
          3        FETCH_CLASS_CONSTANT                             ~1      'LEAVES_ONLY'
          4        SEND_VAL_EX                                              ~1
          5        DO_FCALL                                      0          
    9     6      > RETURN                                                   null

End of function __construct

Function beginchildren:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jj1Rh
function name:  beginChildren
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   ECHO                                                     '%3Cul%3E'
   13     1      > RETURN                                                   null

End of function beginchildren

Function endchildren:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jj1Rh
function name:  endChildren
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   ECHO                                                     '%3C%2Ful%3E%0A'
   17     1      > RETURN                                                   null

End of function endchildren

End of class ULRows.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.76 ms | 1404 KiB | 16 Q