3v4l.org

run code in 300+ PHP versions simultaneously
<?php $_REQUEST["name"] = [ null, "myName", " ", "test1" ]; $_REQUEST["email"] = [ null, "myEmail", "" ]; $keys = [ "name", "email" ]; $result = array_map(function ($x) { if (is_array($x)) { return array_filter($x, function($y){ return null !== $y && "" !== trim($y); }); } return $x; }, array_intersect_key($_REQUEST, array_flip($keys))); print_r($result);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/433Dh
function name:  (null)
number of ops:  25
compiled vars:  !0 = $keys, !1 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   FETCH_W                      global              $2      '_REQUEST'
          1        ASSIGN_DIM                                               $2, 'name'
    4     2        OP_DATA                                                  <array>
   10     3        FETCH_W                      global              $4      '_REQUEST'
          4        ASSIGN_DIM                                               $4, 'email'
   11     5        OP_DATA                                                  <array>
   16     6        ASSIGN                                                   !0, <array>
   21     7        INIT_FCALL                                               'array_map'
          8        DECLARE_LAMBDA_FUNCTION                          ~7      [0]
   28     9        SEND_VAL                                                 ~7
         10        INIT_FCALL                                               'array_intersect_key'
         11        FETCH_R                      global              ~8      '_REQUEST'
         12        SEND_VAL                                                 ~8
         13        INIT_FCALL                                               'array_flip'
         14        SEND_VAR                                                 !0
         15        DO_ICALL                                         $9      
         16        SEND_VAR                                                 $9
         17        DO_ICALL                                         $10     
         18        SEND_VAR                                                 $10
   21    19        DO_ICALL                                         $11     
         20        ASSIGN                                                   !1, $11
   30    21        INIT_FCALL                                               'print_r'
         22        SEND_VAR                                                 !1
         23        DO_ICALL                                                 
         24      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 9
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/433Dh
function name:  {closure}
number of ops:  11
compiled vars:  !0 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
   22     1        TYPE_CHECK                                  128          !0
          2      > JMPZ                                                     ~1, ->9
   23     3    >   INIT_FCALL                                               'array_filter'
          4        SEND_VAR                                                 !0
          5        DECLARE_LAMBDA_FUNCTION                          ~2      [0]
   25     6        SEND_VAL                                                 ~2
   23     7        DO_ICALL                                         $3      
   25     8      > RETURN                                                   $3
   27     9    > > RETURN                                                   !0
   28    10*     > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 3, Position 2 = 8
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
filename:       /in/433Dh
function name:  {closure}
number of ops:  10
compiled vars:  !0 = $y
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV                                             !0      
   24     1        TYPE_CHECK                                  1020  ~1      !0
          2      > JMPZ_EX                                          ~1      ~1, ->8
          3    >   INIT_FCALL                                               'trim'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $2      
          6        IS_NOT_IDENTICAL                                 ~3      $2, ''
          7        BOOL                                             ~1      ~3
          8    > > RETURN                                                   ~1
   25     9*     > RETURN                                                   null

End of Dynamic Function 0

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.8 ms | 1015 KiB | 19 Q