3v4l.org

run code in 300+ PHP versions simultaneously
<?php function allowedArgs($input, $allowed) { return array_filter( $input, function ($key) use ($allowed) { return in_array($key, $allowed); }, ARRAY_FILTER_USE_KEY ); } function example($args) { extract(allowedArgs($args, ['foo', 'bar'])); var_dump($foo, $bar, $baz); } example(['bar' => 2, 'foo' => 1, 'baz'=> 3]);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/odZr7
function name:  (null)
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   INIT_FCALL                                               'example'
          1        SEND_VAL                                                 <array>
          2        DO_FCALL                                      0          
          3      > RETURN                                                   1

Function allowedargs:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/odZr7
function name:  allowedArgs
number of ops:  11
compiled vars:  !0 = $input, !1 = $allowed
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        INIT_FCALL                                               'array_filter'
    5     3        SEND_VAR                                                 !0
    6     4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FodZr7%3A6%240'
          5        BIND_LEXICAL                                             ~2, !1
    8     6        SEND_VAL                                                 ~2
    9     7        SEND_VAL                                                 2
          8        DO_ICALL                                         $3      
          9      > RETURN                                                   $3
   11    10*     > RETURN                                                   null

End of function allowedargs

Function %00%7Bclosure%7D%2Fin%2FodZr7%3A6%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/odZr7
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $key, !1 = $allowed
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
    7     2        INIT_FCALL                                               'in_array'
          3        SEND_VAR                                                 !0
          4        SEND_VAR                                                 !1
          5        DO_ICALL                                         $2      
          6      > RETURN                                                   $2
    8     7*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FodZr7%3A6%240

Function example:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/odZr7
function name:  example
number of ops:  14
compiled vars:  !0 = $args, !1 = $foo, !2 = $bar, !3 = $baz
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   14     1        INIT_FCALL                                               'extract'
          2        INIT_FCALL                                               'allowedargs'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 <array>
          5        DO_FCALL                                      0  $4      
          6        SEND_VAL                                                 $4
          7        DO_ICALL                                                 
   15     8        INIT_FCALL                                               'var_dump'
          9        SEND_VAR                                                 !1
         10        SEND_VAR                                                 !2
         11        SEND_VAR                                                 !3
         12        DO_ICALL                                                 
   16    13      > RETURN                                                   null

End of function example

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.82 ms | 1403 KiB | 23 Q