3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array( 'a' => 'a', 'b' => null, 'c' => array( 'a' => null, 'b' => 'b', ), 'd' => array( 'a' => null ) ); $result = array_walk_recursive_delete($array, function ($value, $key) { if (is_array($value)) { return empty($value); } }); echo"<pre>"; print_r($result); echo"<pre>"; function array_walk_recursive_delete(array &$array, callable $callback) { foreach ($array as $key => &$value) { if (is_array($value)) { $value = array_walk_recursive_delete($value, $callback); } if ($value == null) { unset($array[$key]); } } return $array; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XVGeK
function name:  (null)
number of ops:  13
compiled vars:  !0 = $array, !1 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   14     1        INIT_FCALL_BY_NAME                                       'array_walk_recursive_delete'
          2        SEND_VAR_EX                                              !0
          3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FXVGeK%3A14%240'
   18     4        SEND_VAL_EX                                              ~3
          5        DO_FCALL                                      0  $4      
   14     6        ASSIGN                                                   !1, $4
   19     7        ECHO                                                     '%3Cpre%3E'
   20     8        INIT_FCALL                                               'print_r'
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                                 
   21    11        ECHO                                                     '%3Cpre%3E'
   34    12      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FXVGeK%3A14%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XVGeK
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $value, !1 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   15     2        TYPE_CHECK                                  128          !0
          3      > JMPZ                                                     ~2, ->6
   16     4    >   ISSET_ISEMPTY_CV                                 ~3      !0
          5      > RETURN                                                   ~3
   18     6    > > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FXVGeK%3A14%240

Function array_walk_recursive_delete:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 3, Position 2 = 16
Branch analysis from position: 3
2 jumps found. (Code = 126) Position 1 = 4, Position 2 = 16
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 12
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 15
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 15
Branch analysis from position: 12
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/XVGeK
function name:  array_walk_recursive_delete
number of ops:  19
compiled vars:  !0 = $array, !1 = $callback, !2 = $value, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   24     2      > FE_RESET_RW                                      $4      !0, ->16
          3    > > FE_FETCH_RW                                      ~5      $4, !2, ->16
          4    >   ASSIGN                                                   !3, ~5
   25     5        TYPE_CHECK                                  128          !2
          6      > JMPZ                                                     ~7, ->12
   26     7    >   INIT_FCALL_BY_NAME                                       'array_walk_recursive_delete'
          8        SEND_VAR_EX                                              !2
          9        SEND_VAR_EX                                              !1
         10        DO_FCALL                                      0  $8      
         11        ASSIGN                                                   !2, $8
   28    12    >   IS_EQUAL                                                 !2, null
         13      > JMPZ                                                     ~10, ->15
   29    14    >   UNSET_DIM                                                !0, !3
   24    15    > > JMP                                                      ->3
         16    >   FE_FREE                                                  $4
   33    17      > RETURN                                                   !0
   34    18*     > RETURN                                                   null

End of function array_walk_recursive_delete

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
198.68 ms | 1400 KiB | 15 Q