3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = [ 'a' => 'value a', 'b' => [ 1 => [], 2 => 'value b2', 3 => [ 'x' => 'value x', 'y' => [ 'value z', '' ] ], 'c' => '' ], 'c' => '' ]; function findEmpties($input, $currentLevel = null) { static $empties = []; foreach ($input as $key => $value) { $levelItem = $currentLevel ? "{$currentLevel}[{$key}]" : $key; if (empty($value)) { $empties['empty'][] = $levelItem; } else { if (is_array($value)) { findEmpties($value, $levelItem); } } } return $empties; } print_r(findEmpties($input));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/22FJe
function name:  (null)
number of ops:  8
compiled vars:  !0 = $input
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   36     1        INIT_FCALL                                               'print_r'
          2        INIT_FCALL                                               'findempties'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function findempties:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 28
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 28
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 13
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 21
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 27
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 27
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 21
Branch analysis from position: 17
Branch analysis from position: 21
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
filename:       /in/22FJe
function name:  findEmpties
number of ops:  31
compiled vars:  !0 = $input, !1 = $currentLevel, !2 = $empties, !3 = $value, !4 = $key, !5 = $levelItem
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
   21     2        BIND_STATIC                                              !2
   23     3      > FE_RESET_R                                       $6      !0, ->28
          4    > > FE_FETCH_R                                       ~7      $6, !3, ->28
          5    >   ASSIGN                                                   !4, ~7
   24     6      > JMPZ                                                     !1, ->13
          7    >   ROPE_INIT                                     4  ~10     !1
          8        ROPE_ADD                                      1  ~10     ~10, '%5B'
          9        ROPE_ADD                                      2  ~10     ~10, !4
         10        ROPE_END                                      3  ~9      ~10, '%5D'
         11        QM_ASSIGN                                        ~12     ~9
         12      > JMP                                                      ->14
         13    >   QM_ASSIGN                                        ~12     !4
         14    >   ASSIGN                                                   !5, ~12
   25    15        ISSET_ISEMPTY_CV                                         !3
         16      > JMPZ                                                     ~14, ->21
   26    17    >   FETCH_DIM_W                                      $15     !2, 'empty'
         18        ASSIGN_DIM                                               $15
         19        OP_DATA                                                  !5
   25    20      > JMP                                                      ->27
   28    21    >   TYPE_CHECK                                  128          !3
         22      > JMPZ                                                     ~17, ->27
   29    23    >   INIT_FCALL_BY_NAME                                       'findEmpties'
         24        SEND_VAR_EX                                              !3
         25        SEND_VAR_EX                                              !5
         26        DO_FCALL                                      0          
   23    27    > > JMP                                                      ->4
         28    >   FE_FREE                                                  $6
   34    29      > RETURN                                                   !2
   35    30*     > RETURN                                                   null

End of function findempties

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141 ms | 1017 KiB | 15 Q