3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ 'ip' => '127.0.0.1', 'user_agent' => 'dkdkdk', '_id' => 'fjjfjf', 'user' => [ 'longName' => '', 'shortName' => '', 'username' => [ 'a' => 'b', 'c' => '' ] ], 'dsd' => [ 'zz' => [ 'dd' => [ 'ff' => '' ] ] ], 'dsddd' => '', 'vcv' => null, 'aavx' => 0 ]; function removeEmptyArrays(&$array){ foreach($array as $key => &$value){ if(is_array($value)) removeEmptyArrays($value); if(is_array($value) && count($value) == 0 || is_null($value) || is_string($value) && strlen($value) == 0) unset($array[$key]); } } removeEmptyArrays($array); print_r($array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XDJdD
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>
   34     1        INIT_FCALL                                               'removeemptyarrays'
          2        SEND_REF                                                 !0
          3        DO_FCALL                                      0          
   35     4        INIT_FCALL                                               'print_r'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

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

End of function removeemptyarrays

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.87 ms | 1009 KiB | 15 Q