3v4l.org

run code in 300+ PHP versions simultaneously
<?php function recursive_select($data, callable $callback, $flag = \RecursiveIteratorIterator::SELF_FIRST, $preserve_keys = FALSE) { return iterator_to_array(new \CallbackFilterIterator(new \RecursiveIteratorIterator(new \RecursiveArrayIterator($data), $flag), $callback), $preserve_keys); } $multi=[['A',['B',['CC','CCCC','CCCCCC'],['DDD','EFG','HIJ','LMNOP']]],['2'],'b',[[],[],[]]]; $array = array(1,2,[3,4],5,'six',array(array('78',9)),10); $multi_output = recursive_select($multi, function ($value) { return is_string($value); }); $array_output = recursive_select($array, function ($value) { return is_numeric($value) || is_string($value); }); var_dump($multi_output, $array_output);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TDIvu
function name:  (null)
number of ops:  19
compiled vars:  !0 = $multi, !1 = $array, !2 = $multi_output, !3 = $array_output
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   ASSIGN                                                   !0, <array>
    8     1        ASSIGN                                                   !1, <array>
   11     2        INIT_FCALL                                               'recursive_select'
          3        SEND_VAR                                                 !0
          4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FTDIvu%3A11%240'
   13     5        SEND_VAL                                                 ~6
          6        DO_FCALL                                      0  $7      
   11     7        ASSIGN                                                   !2, $7
   15     8        INIT_FCALL                                               'recursive_select'
          9        SEND_VAR                                                 !1
         10        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FTDIvu%3A15%241'
   17    11        SEND_VAL                                                 ~9
         12        DO_FCALL                                      0  $10     
   15    13        ASSIGN                                                   !3, $10
   19    14        INIT_FCALL                                               'var_dump'
         15        SEND_VAR                                                 !2
         16        SEND_VAR                                                 !3
         17        DO_ICALL                                                 
         18      > RETURN                                                   1

Function recursive_select:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TDIvu
function name:  recursive_select
number of ops:  21
compiled vars:  !0 = $data, !1 = $callback, !2 = $flag, !3 = $preserve_keys
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      <const ast>
          3        RECV_INIT                                        !3      <false>
    4     4        INIT_FCALL                                               'iterator_to_array'
          5        NEW                                              $4      'CallbackFilterIterator'
          6        NEW                                              $5      'RecursiveIteratorIterator'
          7        NEW                                              $6      'RecursiveArrayIterator'
          8        SEND_VAR_EX                                              !0
          9        DO_FCALL                                      0          
         10        SEND_VAR_NO_REF_EX                                       $6
         11        SEND_VAR_EX                                              !2
         12        DO_FCALL                                      0          
         13        SEND_VAR_NO_REF_EX                                       $5
         14        SEND_VAR_EX                                              !1
         15        DO_FCALL                                      0          
         16        SEND_VAR                                                 $4
         17        SEND_VAR                                                 !3
         18        DO_ICALL                                         $10     
         19      > RETURN                                                   $10
    5    20*     > RETURN                                                   null

End of function recursive_select

Function %00%7Bclosure%7D%2Fin%2FTDIvu%3A11%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TDIvu
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   12     1        TYPE_CHECK                                   64  ~1      !0
          2      > RETURN                                                   ~1
   13     3*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FTDIvu%3A11%240

Function %00%7Bclosure%7D%2Fin%2FTDIvu%3A15%241:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 5, Position 2 = 7
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
filename:       /in/TDIvu
function name:  {closure}
number of ops:  9
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
   16     1        INIT_FCALL                                               'is_numeric'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $1      
          4      > JMPNZ_EX                                         ~2      $1, ->7
          5    >   TYPE_CHECK                                   64  ~3      !0
          6        BOOL                                             ~2      ~3
          7    > > RETURN                                                   ~2
   17     8*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FTDIvu%3A15%241

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
180.61 ms | 1407 KiB | 21 Q