3v4l.org

run code in 300+ PHP versions simultaneously
<?php $cars = [ 0 => ["id" => 1, "name" => "FORD"], 1 => ["id" => 2, "name" => "BMW"], 2 => ["id" => 3, "name" => "FIAT"], 3 => ["id" => 4, "name" => "RENAULT"], 4 => ["id" => 5, "name" => "BENTLEY"], ]; $selection = [ 0 => "1", 1 => "3", 2 => "4" ]; $cars_by_id = array_column($cars, null, 'id'); $selected_cars = array_intersect_key($cars_by_id, array_flip($selection)); var_dump($selected_cars);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PZstq
function name:  (null)
number of ops:  20
compiled vars:  !0 = $cars, !1 = $selection, !2 = $cars_by_id, !3 = $selected_cars
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, <array>
   12     1        ASSIGN                                                   !1, <array>
   18     2        INIT_FCALL                                               'array_column'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 null
          5        SEND_VAL                                                 'id'
          6        DO_ICALL                                         $6      
          7        ASSIGN                                                   !2, $6
   20     8        INIT_FCALL                                               'array_intersect_key'
          9        SEND_VAR                                                 !2
         10        INIT_FCALL                                               'array_flip'
         11        SEND_VAR                                                 !1
         12        DO_ICALL                                         $8      
         13        SEND_VAR                                                 $8
         14        DO_ICALL                                         $9      
         15        ASSIGN                                                   !3, $9
   22    16        INIT_FCALL                                               'var_dump'
         17        SEND_VAR                                                 !3
         18        DO_ICALL                                                 
         19      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.42 ms | 1013 KiB | 17 Q