3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ (object)['id' => 8], (object)['id' => 7], (object)['id' => 5] ]; $order = [5, 8, 1]; $order = array_flip($order); $keyed = array_column($array, null, 'id'); var_export($keyed); echo "\n---\n"; $filtered_order = array_intersect_key($order, $keyed); var_export($filtered_order); echo "\n---\n"; $replaced = array_replace($filtered_order, $keyed); var_export(array_values($replaced));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bHZE6
function name:  (null)
number of ops:  43
compiled vars:  !0 = $array, !1 = $order, !2 = $keyed, !3 = $filtered_order, !4 = $replaced
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   CAST                                          8  ~5      <array>
          1        INIT_ARRAY                                       ~6      ~5
    5     2        CAST                                          8  ~7      <array>
          3        ADD_ARRAY_ELEMENT                                ~6      ~7
    6     4        CAST                                          8  ~8      <array>
          5        ADD_ARRAY_ELEMENT                                ~6      ~8
    3     6        ASSIGN                                                   !0, ~6
    9     7        ASSIGN                                                   !1, <array>
   11     8        INIT_FCALL                                               'array_flip'
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                         $11     
         11        ASSIGN                                                   !1, $11
   12    12        INIT_FCALL                                               'array_column'
         13        SEND_VAR                                                 !0
         14        SEND_VAL                                                 null
         15        SEND_VAL                                                 'id'
         16        DO_ICALL                                         $13     
         17        ASSIGN                                                   !2, $13
   13    18        INIT_FCALL                                               'var_export'
         19        SEND_VAR                                                 !2
         20        DO_ICALL                                                 
   14    21        ECHO                                                     '%0A---%0A'
   15    22        INIT_FCALL                                               'array_intersect_key'
         23        SEND_VAR                                                 !1
         24        SEND_VAR                                                 !2
         25        DO_ICALL                                         $16     
         26        ASSIGN                                                   !3, $16
   16    27        INIT_FCALL                                               'var_export'
         28        SEND_VAR                                                 !3
         29        DO_ICALL                                                 
   17    30        ECHO                                                     '%0A---%0A'
   18    31        INIT_FCALL                                               'array_replace'
         32        SEND_VAR                                                 !3
         33        SEND_VAR                                                 !2
         34        DO_ICALL                                         $19     
         35        ASSIGN                                                   !4, $19
   19    36        INIT_FCALL                                               'var_export'
         37        INIT_FCALL                                               'array_values'
         38        SEND_VAR                                                 !4
         39        DO_ICALL                                         $21     
         40        SEND_VAR                                                 $21
         41        DO_ICALL                                                 
         42      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
208.82 ms | 1008 KiB | 19 Q