3v4l.org

run code in 300+ PHP versions simultaneously
<?php $records = [(object)['id' => 1], (object)['id' => 2], (object)['id' => 3]]; $sorted = ['2' => 7, '3' => 4, '1' => 2]; $tempArr = array(); foreach ($records as $value) { $tempArr[$value->id] = $value; // $value IS an object } $resultArr = array_values(array_replace($sorted, $tempArr)); var_export($resultArr);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 15
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 15
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/5CBeo
function name:  (null)
number of ops:  28
compiled vars:  !0 = $records, !1 = $sorted, !2 = $tempArr, !3 = $value, !4 = $resultArr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   CAST                                          8  ~5      <array>
          1        INIT_ARRAY                                       ~6      ~5
          2        CAST                                          8  ~7      <array>
          3        ADD_ARRAY_ELEMENT                                ~6      ~7
          4        CAST                                          8  ~8      <array>
          5        ADD_ARRAY_ELEMENT                                ~6      ~8
          6        ASSIGN                                                   !0, ~6
    4     7        ASSIGN                                                   !1, <array>
    6     8        ASSIGN                                                   !2, <array>
    7     9      > FE_RESET_R                                       $12     !0, ->15
         10    > > FE_FETCH_R                                               $12, !3, ->15
    8    11    >   FETCH_OBJ_R                                      ~13     !3, 'id'
         12        ASSIGN_DIM                                               !2, ~13
         13        OP_DATA                                                  !3
    7    14      > JMP                                                      ->10
         15    >   FE_FREE                                                  $12
   10    16        INIT_FCALL                                               'array_values'
         17        INIT_FCALL                                               'array_replace'
         18        SEND_VAR                                                 !1
         19        SEND_VAR                                                 !2
         20        DO_ICALL                                         $15     
         21        SEND_VAR                                                 $15
         22        DO_ICALL                                         $16     
         23        ASSIGN                                                   !4, $16
   12    24        INIT_FCALL                                               'var_export'
         25        SEND_VAR                                                 !4
         26        DO_ICALL                                                 
         27      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.01 ms | 1008 KiB | 16 Q