3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array( 0 => array (0 => null, 1=> 'something1'), 1 => array (0 => null, 1=> null, 2 => 'something2', 3 => array(0 => null, 1 => 'f')), 2 => null ); function filterNulls($array, &$list = []) { array_walk($array, function ($value, $key) use (&$list) { if (!is_array($value)) { if (!empty($value)) { $list[$key] = $value; } } else { $list[$key] = filterNulls($value); } }); return $list; } print_r(filterNulls($array));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IDdYD
function name:  (null)
number of ops:  8
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   24     1        INIT_FCALL                                               'print_r'
          2        INIT_FCALL                                               'filternulls'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function filternulls:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IDdYD
function name:  filterNulls
number of ops:  10
compiled vars:  !0 = $array, !1 = $list
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <array>
   11     2        INIT_FCALL                                               'array_walk'
          3        SEND_REF                                                 !0
          4        DECLARE_LAMBDA_FUNCTION                          ~2      [0]
          5        BIND_LEXICAL                                             ~2, !1
   19     6        SEND_VAL                                                 ~2
   11     7        DO_ICALL                                                 
   21     8      > RETURN                                                   !1
   22     9*     > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 12
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IDdYD
function name:  {closure}
number of ops:  18
compiled vars:  !0 = $value, !1 = $key, !2 = $list
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
   12     3        TYPE_CHECK                                  128  ~3      !0
          4        BOOL_NOT                                         ~4      ~3
          5      > JMPZ                                                     ~4, ->12
   13     6    >   ISSET_ISEMPTY_CV                                 ~5      !0
          7        BOOL_NOT                                         ~6      ~5
          8      > JMPZ                                                     ~6, ->11
   14     9    >   ASSIGN_DIM                                               !2, !1
         10        OP_DATA                                                  !0
   12    11    > > JMP                                                      ->17
   17    12    >   INIT_FCALL_BY_NAME                                       'filterNulls'
         13        SEND_VAR_EX                                              !0
         14        DO_FCALL                                      0  $9      
         15        ASSIGN_DIM                                               !2, !1
         16        OP_DATA                                                  $9
   19    17    > > RETURN                                                   null

End of Dynamic Function 0

End of function filternulls

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.06 ms | 1006 KiB | 16 Q