3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array( array ( '45' => array( '1 day' ) ), array ( '45' => array( '- None -' ) ), '- None -' ); function removeNoneElements(&$arr){ $temp = $arr; $hasNone = false; foreach($temp as $index => $val){ if(is_array($val)){ $containsNone = removeNoneElements($val); if($containsNone){ $hasNone = true; unset($arr[$index]); } }else if($val === '- None -'){ unset($arr[$index]); $hasNone = true; } } return $hasNone; } echo "Before Removal",PHP_EOL; print_r($arr); removeNoneElements($arr); echo "After Removal",PHP_EOL; print_r($arr);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/N3AP3
function name:  (null)
number of ops:  15
compiled vars:  !0 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   39     1        ECHO                                                     'Before+Removal'
          2        ECHO                                                     '%0A'
   40     3        INIT_FCALL                                               'print_r'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                                 
   41     6        INIT_FCALL                                               'removenoneelements'
          7        SEND_REF                                                 !0
          8        DO_FCALL                                      0          
   42     9        ECHO                                                     'After+Removal'
         10        ECHO                                                     '%0A'
   43    11        INIT_FCALL                                               'print_r'
         12        SEND_VAR                                                 !0
         13        DO_ICALL                                                 
         14      > RETURN                                                   1

Function removenoneelements:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 21
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 21
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 16
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 15
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 15
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 20
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 20
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
filename:       /in/N3AP3
function name:  removeNoneElements
number of ops:  24
compiled vars:  !0 = $arr, !1 = $temp, !2 = $hasNone, !3 = $val, !4 = $index, !5 = $containsNone
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
   21     1        ASSIGN                                                   !1, !0
   22     2        ASSIGN                                                   !2, <false>
   23     3      > FE_RESET_R                                       $8      !1, ->21
          4    > > FE_FETCH_R                                       ~9      $8, !3, ->21
          5    >   ASSIGN                                                   !4, ~9
   24     6        TYPE_CHECK                                  128          !3
          7      > JMPZ                                                     ~11, ->16
   25     8    >   INIT_FCALL_BY_NAME                                       'removeNoneElements'
          9        SEND_VAR_EX                                              !3
         10        DO_FCALL                                      0  $12     
         11        ASSIGN                                                   !5, $12
   26    12      > JMPZ                                                     !5, ->15
   27    13    >   ASSIGN                                                   !2, <true>
   28    14        UNSET_DIM                                                !0, !4
         15    > > JMP                                                      ->20
   30    16    >   IS_IDENTICAL                                             !3, '-+None+-'
         17      > JMPZ                                                     ~15, ->20
   31    18    >   UNSET_DIM                                                !0, !4
   32    19        ASSIGN                                                   !2, <true>
   23    20    > > JMP                                                      ->4
         21    >   FE_FREE                                                  $8
   36    22      > RETURN                                                   !2
   37    23*     > RETURN                                                   null

End of function removenoneelements

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
195.79 ms | 1403 KiB | 16 Q