3v4l.org

run code in 300+ PHP versions simultaneously
<?php $keys = array( 'staff_first_name' => NULL, 'staff_last_name' => NULL, 'staff_years' => NULL ); $values = array( 'id' => 123, 'years' => 5, 'department' => "IT", 'first_name' => 'jon', 'last_name' => 'doe', ); $val = preg_grep("/first_name|last_name|years/",array_values(array_flip($values))); $values = Array_intersect_key($values, array_flip($val)); ksort($values); ksort($keys); Var_dump(array_combine(array_keys($keys), $values));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/a3ju1
function name:  (null)
number of ops:  38
compiled vars:  !0 = $keys, !1 = $values, !2 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   10     1        ASSIGN                                                   !1, <array>
   17     2        INIT_FCALL                                               'preg_grep'
          3        SEND_VAL                                                 '%2Ffirst_name%7Clast_name%7Cyears%2F'
          4        INIT_FCALL                                               'array_values'
          5        INIT_FCALL                                               'array_flip'
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                         $5      
          8        SEND_VAR                                                 $5
          9        DO_ICALL                                         $6      
         10        SEND_VAR                                                 $6
         11        DO_ICALL                                         $7      
         12        ASSIGN                                                   !2, $7
   19    13        INIT_FCALL                                               'array_intersect_key'
         14        SEND_VAR                                                 !1
         15        INIT_FCALL                                               'array_flip'
         16        SEND_VAR                                                 !2
         17        DO_ICALL                                         $9      
         18        SEND_VAR                                                 $9
         19        DO_ICALL                                         $10     
         20        ASSIGN                                                   !1, $10
   20    21        INIT_FCALL                                               'ksort'
         22        SEND_REF                                                 !1
         23        DO_ICALL                                                 
   21    24        INIT_FCALL                                               'ksort'
         25        SEND_REF                                                 !0
         26        DO_ICALL                                                 
   24    27        INIT_FCALL                                               'var_dump'
         28        INIT_FCALL                                               'array_combine'
         29        INIT_FCALL                                               'array_keys'
         30        SEND_VAR                                                 !0
         31        DO_ICALL                                         $14     
         32        SEND_VAR                                                 $14
         33        SEND_VAR                                                 !1
         34        DO_ICALL                                         $15     
         35        SEND_VAR                                                 $15
         36        DO_ICALL                                                 
         37      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.83 ms | 1409 KiB | 29 Q