3v4l.org

run code in 300+ PHP versions simultaneously
<?php function wrap( $arr){ test( $arr); } function test( $arr){ $refs = array(); // Array of references that we've seen $f = function( $arr) use( &$refs, &$f) { $refs[] = $arr; foreach( $arr as $v) { if( in_array( $v, $refs, true)) { print 'ref, '; } else { if( is_array( $v)) { $f( $v); } else { print $v . ', '; } } } }; $f( $arr); } $array = array(1, 2, array(1, 2), array(1, 2)); wrap( $array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/clqMi
function name:  (null)
number of ops:  5
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   ASSIGN                                                   !0, <array>
   27     1        INIT_FCALL                                               'wrap'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0          
          4      > RETURN                                                   1

Function wrap:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/clqMi
function name:  wrap
number of ops:  5
compiled vars:  !0 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        INIT_FCALL_BY_NAME                                       'test'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
    4     4      > RETURN                                                   null

End of function wrap

Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/clqMi
function name:  test
number of ops:  10
compiled vars:  !0 = $arr, !1 = $refs, !2 = $f
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    7     1        ASSIGN                                                   !1, <array>
    9     2        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FclqMi%3A9%240'
          3        BIND_LEXICAL                                             ~4, !1
          4        BIND_LEXICAL                                             ~4, !2
          5        ASSIGN                                                   !2, ~4
   23     6        INIT_DYNAMIC_CALL                                        !2
          7        SEND_VAR_EX                                              !0
          8        DO_FCALL                                      0          
   24     9      > RETURN                                                   null

End of function test

Function %00%7Bclosure%7D%2Fin%2FclqMi%3A9%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 24
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 24
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 15
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 21
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
filename:       /in/clqMi
function name:  {closure}
number of ops:  26
compiled vars:  !0 = $arr, !1 = $refs, !2 = $f, !3 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        BIND_STATIC                                              !2
   10     3        ASSIGN_DIM                                               !1
          4        OP_DATA                                                  !0
   11     5      > FE_RESET_R                                       $5      !0, ->24
          6    > > FE_FETCH_R                                               $5, !3, ->24
   12     7    >   INIT_FCALL                                               'in_array'
          8        SEND_VAR                                                 !3
          9        SEND_VAR                                                 !1
         10        SEND_VAL                                                 <true>
         11        DO_ICALL                                         $6      
         12      > JMPZ                                                     $6, ->15
   13    13    >   ECHO                                                     'ref%2C+'
         14      > JMP                                                      ->23
   15    15    >   TYPE_CHECK                                  128          !3
         16      > JMPZ                                                     ~7, ->21
   16    17    >   INIT_DYNAMIC_CALL                                        !2
         18        SEND_VAR_EX                                              !3
         19        DO_FCALL                                      0          
         20      > JMP                                                      ->23
   18    21    >   CONCAT                                           ~9      !3, '%2C+'
         22        ECHO                                                     ~9
   11    23    > > JMP                                                      ->6
         24    >   FE_FREE                                                  $5
   22    25      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FclqMi%3A9%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
179.99 ms | 1394 KiB | 16 Q