3v4l.org

run code in 300+ PHP versions simultaneously
<?php function prune_leaves($array) { foreach($array as $k => $v) { var_dump($v, NULL, $v === NULL); if ($v === NULL) unset($array[$k]); if (is_array($v)) prune_leaves($v); } return $array; } $test1 = ['a' => 123, 'b' => ['c' => null]]; var_dump(prune_leaves($test1));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Fig5b
function name:  (null)
number of ops:  8
compiled vars:  !0 = $test1
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   ASSIGN                                                   !0, <array>
   13     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'prune_leaves'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function prune_leaves:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 19
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 19
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 13
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 18
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 18
Branch analysis from position: 13
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
filename:       /in/Fig5b
function name:  prune_leaves
number of ops:  22
compiled vars:  !0 = $array, !1 = $v, !2 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1      > FE_RESET_R                                       $3      !0, ->19
          2    > > FE_FETCH_R                                       ~4      $3, !1, ->19
          3    >   ASSIGN                                                   !2, ~4
    5     4        INIT_FCALL                                               'var_dump'
          5        SEND_VAR                                                 !1
          6        SEND_VAL                                                 null
          7        TYPE_CHECK                                    2  ~6      !1
          8        SEND_VAL                                                 ~6
          9        DO_ICALL                                                 
    6    10        TYPE_CHECK                                    2          !1
         11      > JMPZ                                                     ~8, ->13
         12    >   UNSET_DIM                                                !0, !2
    7    13    >   TYPE_CHECK                                  128          !1
         14      > JMPZ                                                     ~9, ->18
         15    >   INIT_FCALL_BY_NAME                                       'prune_leaves'
         16        SEND_VAR_EX                                              !1
         17        DO_FCALL                                      0          
    4    18    > > JMP                                                      ->2
         19    >   FE_FREE                                                  $3
    9    20      > RETURN                                                   !0
   10    21*     > RETURN                                                   null

End of function prune_leaves

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.91 ms | 1399 KiB | 16 Q