3v4l.org

run code in 500+ PHP versions simultaneously
<?php function flatten(array $nestedArraysAndStrings){ $flat=[]; $iter = new RecursiveIteratorIterator( new RecursiveArrayIterator($nestedArraysAndStrings)); foreach($iter as $leaf){ $flat[] = $leaf; } return join(NULL, $flat); } $noRefs = [[[['some']]],[' nested ']," items n"]; $withRefs = []+$noRefs; $wat = $noRefs[0]; $withRefs[0] = &$wat; echo flatten($noRefs); echo flatten($withRefs);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/up3me
function name:  (null)
number of ops:  16
compiled vars:  !0 = $noRefs, !1 = $withRefs, !2 = $wat
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   ASSIGN                                                       !0, <array>
   13     1        ADD                                                  ~4      <array>, !0
          2        ASSIGN                                                       !1, ~4
   14     3        FETCH_DIM_R                                          ~6      !0, 0
          4        ASSIGN                                                       !2, ~6
   15     5        FETCH_DIM_W                                          $8      !1, 0
          6        ASSIGN_REF                                                   $8, !2
   17     7        INIT_FCALL                                                   'flatten'
          8        SEND_VAR                                                     !0
          9        DO_FCALL                                          0  $10     
         10        ECHO                                                         $10
   18    11        INIT_FCALL                                                   'flatten'
         12        SEND_VAR                                                     !1
         13        DO_FCALL                                          0  $11     
         14        ECHO                                                         $11
         15      > RETURN                                                       1

Function flatten:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 14
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 14
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
filename:       /in/up3me
function name:  flatten
number of ops:  21
compiled vars:  !0 = $nestedArraysAndStrings, !1 = $flat, !2 = $iter, !3 = $leaf
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
    4     1        ASSIGN                                                       !1, <array>
    5     2        NEW                                                  $5      'RecursiveIteratorIterator'
    6     3        NEW                                                  $6      'RecursiveArrayIterator'
          4        SEND_VAR_EX                                                  !0
          5        DO_FCALL                                          0          
          6        SEND_VAR_NO_REF_EX                                           $6
    5     7        DO_FCALL                                          0          
          8        ASSIGN                                                       !2, $5
    7     9      > FE_RESET_R                                           $10     !2, ->14
         10    > > FE_FETCH_R                                                   $10, !3, ->14
         11    >   ASSIGN_DIM                                                   !1
         12        OP_DATA                                                      !3
         13      > JMP                                                          ->10
         14    >   FE_FREE                                                      $10
    8    15        INIT_FCALL                                                   'join'
         16        SEND_VAL                                                     null
         17        SEND_VAR                                                     !1
         18        DO_ICALL                                             $12     
         19      > RETURN                                                       $12
    9    20*     > RETURN                                                       null

End of function flatten

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
167.79 ms | 3322 KiB | 16 Q