3v4l.org

run code in 300+ PHP versions simultaneously
<?php $raw = array( 'firstname' => 'Foo', 'lastname' => 'Bar', 'nickname' => '', 'birthdate' => array( 'day' => '', 'month' => '', 'year' => '', ), 'likes' => array( 'cars' => array('Subaru Impreza WRX STi', 'Mitsubishi Evo', 'Nissan GTR'), 'bikes' => array(), ), ); $callback = function($item) use (&$callback) { if (is_array($item)) { return array_filter($item, $callback); } if (!empty($item)) { return true; } }; var_dump(array_filter($raw, $callback)); $navigation = array( array( "title" => "Overzicht", "enabled" => 0, "submenu" => array( array( "title" => "Dashboard", "url" => "dashboard/", "module" => "Home", "icon" => "icon-home", "userlevel" => 0, "enabled" => 1 ), array( "title" => "Mijn statistieken", "url" => "user/stats/", "module" => "User", "icon" => "icon-stats", "userlevel" => 60, "enabled" => 1 ) ) ), array( "title" => "Acties", "enabled" => 1, "submenu" => array( array( "title" => "Alle acties", "url" => "action/", "module" => "Action", "icon" => "icon-list-alt", "userlevel" => 0, "enabled" => 0 ), array( "title" => "Mijn acties", "url" => "action/:user_id/", "module" => "Action", "icon" => "icon-list", "userlevel" => 60, "enabled" => 1 ), array( "title" => "Nieuwe actie", "url" => "new/", "module" => "Action", "icon" => "icon-plus", "userlevel" => 80, "enabled" => 1 ) ) ) ); $filterFunc = function($arr) use (&$filterFunc) { foreach ($arr as &$v) { if (!$v["enabled"]) unset($v); if (isset($v["userlevel"])) { if (($v["userlevel"] > 60)) unset($v); } if (isset($v["submenu"])) { $v["submenu"] = $filterFunc($v["submenu"]); } } return $arr; }; $navigation = $filterFunc($navigation); var_dump($navigation);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vAfdi
function name:  (null)
number of ops:  23
compiled vars:  !0 = $raw, !1 = $callback, !2 = $navigation, !3 = $filterFunc
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   16     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FvAfdi%3A16%240'
          2        BIND_LEXICAL                                             ~5, !1
          3        ASSIGN                                                   !1, ~5
   25     4        INIT_FCALL                                               'var_dump'
          5        INIT_FCALL                                               'array_filter'
          6        SEND_VAR                                                 !0
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                         $7      
          9        SEND_VAR                                                 $7
         10        DO_ICALL                                                 
   27    11        ASSIGN                                                   !2, <array>
   83    12        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FvAfdi%3A83%241'
         13        BIND_LEXICAL                                             ~10, !3
         14        ASSIGN                                                   !3, ~10
  100    15        INIT_DYNAMIC_CALL                                        !3
         16        SEND_VAR_EX                                              !2
         17        DO_FCALL                                      0  $12     
         18        ASSIGN                                                   !2, $12
  102    19        INIT_FCALL                                               'var_dump'
         20        SEND_VAR                                                 !2
         21        DO_ICALL                                                 
         22      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FvAfdi%3A16%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 9
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 13
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vAfdi
function name:  {closure}
number of ops:  14
compiled vars:  !0 = $item, !1 = $callback
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   17     2        TYPE_CHECK                                  128          !0
          3      > JMPZ                                                     ~2, ->9
   18     4    >   INIT_FCALL                                               'array_filter'
          5        SEND_VAR                                                 !0
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                         $3      
          8      > RETURN                                                   $3
   20     9    >   ISSET_ISEMPTY_CV                                 ~4      !0
         10        BOOL_NOT                                         ~5      ~4
         11      > JMPZ                                                     ~5, ->13
   21    12    > > RETURN                                                   <true>
   23    13    > > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FvAfdi%3A16%240

Function %00%7Bclosure%7D%2Fin%2FvAfdi%3A83%241:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 3, Position 2 = 24
Branch analysis from position: 3
2 jumps found. (Code = 126) Position 1 = 4, Position 2 = 24
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 8
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 14
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 14
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 23
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 23
Branch analysis from position: 14
Branch analysis from position: 14
Branch analysis from position: 8
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
filename:       /in/vAfdi
function name:  {closure}
number of ops:  27
compiled vars:  !0 = $arr, !1 = $filterFunc, !2 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   83     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   84     2      > FE_RESET_RW                                      $3      !0, ->24
          3    > > FE_FETCH_RW                                              $3, !2, ->24
   85     4    >   FETCH_DIM_R                                      ~4      !2, 'enabled'
          5        BOOL_NOT                                         ~5      ~4
          6      > JMPZ                                                     ~5, ->8
   86     7    >   UNSET_CV                                                 !2
   88     8    >   ISSET_ISEMPTY_DIM_OBJ                         0          !2, 'userlevel'
          9      > JMPZ                                                     ~6, ->14
   89    10    >   FETCH_DIM_R                                      ~7      !2, 'userlevel'
         11        IS_SMALLER                                               60, ~7
         12      > JMPZ                                                     ~8, ->14
   90    13    >   UNSET_CV                                                 !2
   92    14    >   ISSET_ISEMPTY_DIM_OBJ                         0          !2, 'submenu'
         15      > JMPZ                                                     ~9, ->23
   93    16    >   INIT_DYNAMIC_CALL                                        !1
         17        CHECK_FUNC_ARG                                           
         18        FETCH_DIM_FUNC_ARG                               $11     !2, 'submenu'
         19        SEND_FUNC_ARG                                            $11
         20        DO_FCALL                                      0  $12     
         21        ASSIGN_DIM                                               !2, 'submenu'
         22        OP_DATA                                                  $12
   84    23    > > JMP                                                      ->3
         24    >   FE_FREE                                                  $3
   97    25      > RETURN                                                   !0
   98    26*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FvAfdi%3A83%241

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
174.84 ms | 1400 KiB | 17 Q