3v4l.org

run code in 300+ PHP versions simultaneously
<?php function prune_leaves($array) { foreach($array as $k => $v) { 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/7Y5VH
function name:  (null)
number of ops:  8
compiled vars:  !0 = $test1
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   ASSIGN                                                   !0, <array>
   12     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 = 13
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 13
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 7
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 12
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 12
Branch analysis from position: 7
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/7Y5VH
function name:  prune_leaves
number of ops:  16
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, ->13
          2    > > FE_FETCH_R                                       ~4      $3, !1, ->13
          3    >   ASSIGN                                                   !2, ~4
    5     4        TYPE_CHECK                                    2          !1
          5      > JMPZ                                                     ~6, ->7
          6    >   UNSET_DIM                                                !0, !2
    6     7    >   TYPE_CHECK                                  128          !1
          8      > JMPZ                                                     ~7, ->12
          9    >   INIT_FCALL_BY_NAME                                       'prune_leaves'
         10        SEND_VAR_EX                                              !1
         11        DO_FCALL                                      0          
    4    12    > > JMP                                                      ->2
         13    >   FE_FREE                                                  $3
    8    14      > RETURN                                                   !0
    9    15*     > RETURN                                                   null

End of function prune_leaves

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.23 ms | 1399 KiB | 16 Q