3v4l.org

run code in 300+ PHP versions simultaneously
<?php $combined = array( 'A' => array( 'B' => array( 'C' => array(1, null), ), 'D' => array( 'K' => array(null, null), ) ), ); function _nullifyEmpty(array $array) { $nulls = 0; foreach ($array as $key => $value) { if (is_array($value)) { $array[$key] = $value = _nullifyEmpty($value); } if (null === $value) { ++$nulls; } } if ($nulls === count($array)) { return null; } return $array; } print_r(_nullifyEmpty($combined));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RcZcR
function name:  (null)
number of ops:  8
compiled vars:  !0 = $combined
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   32     1        INIT_FCALL                                               'print_r'
          2        INIT_FCALL                                               '_nullifyempty'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function _nullifyempty:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 17
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 17
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 13
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 16
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 16
Branch analysis from position: 13
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 22
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/RcZcR
function name:  _nullifyEmpty
number of ops:  24
compiled vars:  !0 = $array, !1 = $nulls, !2 = $value, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   15     1        ASSIGN                                                   !1, 0
   17     2      > FE_RESET_R                                       $5      !0, ->17
          3    > > FE_FETCH_R                                       ~6      $5, !2, ->17
          4    >   ASSIGN                                                   !3, ~6
   18     5        TYPE_CHECK                                  128          !2
          6      > JMPZ                                                     ~8, ->13
   19     7    >   INIT_FCALL_BY_NAME                                       '_nullifyEmpty'
          8        SEND_VAR_EX                                              !2
          9        DO_FCALL                                      0  $10     
         10        ASSIGN                                           ~11     !2, $10
         11        ASSIGN_DIM                                               !0, !3
         12        OP_DATA                                                  ~11
   21    13    >   TYPE_CHECK                                    2          !2
         14      > JMPZ                                                     ~12, ->16
   22    15    >   PRE_INC                                                  !1
   17    16    > > JMP                                                      ->3
         17    >   FE_FREE                                                  $5
   26    18        COUNT                                            ~14     !0
         19        IS_IDENTICAL                                             !1, ~14
         20      > JMPZ                                                     ~15, ->22
   27    21    > > RETURN                                                   null
   30    22    > > RETURN                                                   !0
   31    23*     > RETURN                                                   null

End of function _nullifyempty

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.33 ms | 1403 KiB | 16 Q