3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Array representing a possible record set returned from a database $records = array( array( 'id' => "bbb", 'first_name' => 'John', 'last_name' => 'Doe', ), array( 'id' => "aaa", 'first_name' => 'Sally', 'last_name' => array( 'id' => "zzz", 'first_name' => 'Sully', 'last_name' => 'Smith', ), ), array( 'id' => "yyy", 'first_name' => 'Jane', 'last_name' => 'Jones', ), array( 'id' => "xxx", 'first_name' => 'Peter', 'last_name' => 'Doe', ) ); /* function test_print($val, $key, &$third) { // var_export($val); // var_export($key); // var_export($third); // $third++; if($key == 'first_name'){ $third[] = $val; } else { print_r($key); } } $third = []; array_walk_recursive($records, 'test_print', $third); print_r($third);*/ foreach (new RecursiveIteratorIterator(new RecursiveArrayIterator($records), RecursiveIteratorIterator::CATCH_GET_CHILD) as $key => $value) { echo 'My node ' . $key . ' with value ' . $value . PHP_EOL; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 17
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 17
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/65ALG
function name:  (null)
number of ops:  19
compiled vars:  !0 = $records, !1 = $value, !2 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, <array>
   48     1        NEW                                              $4      'RecursiveIteratorIterator'
          2        NEW                                              $5      'RecursiveArrayIterator'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0          
          5        SEND_VAR_NO_REF_EX                                       $5
          6        SEND_VAL_EX                                              16
          7        DO_FCALL                                      0          
          8      > FE_RESET_R                                       $8      $4, ->17
          9    > > FE_FETCH_R                                       ~9      $8, !1, ->17
         10    >   ASSIGN                                                   !2, ~9
   49    11        CONCAT                                           ~11     'My+node+', !2
         12        CONCAT                                           ~12     ~11, '+with+value+'
         13        CONCAT                                           ~13     ~12, !1
         14        CONCAT                                           ~14     ~13, '%0A'
         15        ECHO                                                     ~14
   48    16      > JMP                                                      ->9
         17    >   FE_FREE                                                  $8
   50    18      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.44 ms | 1393 KiB | 13 Q