3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ ['toxic', 'irritant', 'flammable'], ['toxic', 'irritant'], ['toxic'], ]; $iterator = new RecursiveIteratorIterator( new RecursiveArrayIterator($array) ); $result = []; foreach ($iterator as $leafNode) { $result[$leafNode] = ($result[$leafNode] ?? 0) + 1; } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 18
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 18
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
filename:       /in/tVYJJ
function name:  (null)
number of ops:  23
compiled vars:  !0 = $array, !1 = $iterator, !2 = $result, !3 = $leafNode
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    9     1        NEW                                              $5      'RecursiveIteratorIterator'
   10     2        NEW                                              $6      'RecursiveArrayIterator'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0          
          5        SEND_VAR_NO_REF_EX                                       $6
    9     6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $5
   12     8        ASSIGN                                                   !2, <array>
   13     9      > FE_RESET_R                                       $11     !1, ->18
         10    > > FE_FETCH_R                                               $11, !3, ->18
   14    11    >   FETCH_DIM_IS                                     ~13     !2, !3
         12        COALESCE                                         ~14     ~13
         13        QM_ASSIGN                                        ~14     0
         14        ADD                                              ~15     ~14, 1
         15        ASSIGN_DIM                                               !2, !3
         16        OP_DATA                                                  ~15
   13    17      > JMP                                                      ->10
         18    >   FE_FREE                                                  $11
   17    19        INIT_FCALL                                               'var_export'
         20        SEND_VAR                                                 !2
         21        DO_ICALL                                                 
         22      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
197.28 ms | 1010 KiB | 14 Q