3v4l.org

run code in 300+ PHP versions simultaneously
<?php $orders = [ ['order_id' => 44925, 'carrier_tracking_code' => 'LB399189926US'], ['order_id' => 44923, 'carrier_tracking_code' => '9205590221582717353066'], ['order_id' => 44490, 'carrier_tracking_code' => '9205590221582717353080'], ]; $customers = [ 79 => ['order_id' => 44490, 'customers_email_address' => 'test@test.com', 'customers_name' => 'JTest name'], 80 => ['order_id' => 44923, 'customers_email_address' => ' test@test.com', 'customers_name' => 'Test name'], 81 => ['order_id' => 44925, 'customers_email_address' => ' test@test.com', 'customers_name' => 'Test name'] ]; $customer_index = array_combine(array_keys($customers), array_column($customers, 'order_id')); $result = []; foreach ($orders as $key => $order) { $result[$key] = $order; $customer = array_search($order['order_id'], $customer_index); $result[$key]['customer'] = $customer ? $customers[$customer] : []; } print_r($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 16, Position 2 = 35
Branch analysis from position: 16
2 jumps found. (Code = 78) Position 1 = 17, Position 2 = 35
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 30
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
filename:       /in/TLYSI
function name:  (null)
number of ops:  40
compiled vars:  !0 = $orders, !1 = $customers, !2 = $customer_index, !3 = $result, !4 = $order, !5 = $key, !6 = $customer
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    8     1        ASSIGN                                                   !1, <array>
   14     2        INIT_FCALL                                               'array_combine'
          3        INIT_FCALL                                               'array_keys'
          4        SEND_VAR                                                 !1
          5        DO_ICALL                                         $9      
          6        SEND_VAR                                                 $9
          7        INIT_FCALL                                               'array_column'
          8        SEND_VAR                                                 !1
          9        SEND_VAL                                                 'order_id'
         10        DO_ICALL                                         $10     
         11        SEND_VAR                                                 $10
         12        DO_ICALL                                         $11     
         13        ASSIGN                                                   !2, $11
   16    14        ASSIGN                                                   !3, <array>
   18    15      > FE_RESET_R                                       $14     !0, ->35
         16    > > FE_FETCH_R                                       ~15     $14, !4, ->35
         17    >   ASSIGN                                                   !5, ~15
   19    18        ASSIGN_DIM                                               !3, !5
         19        OP_DATA                                                  !4
   21    20        INIT_FCALL                                               'array_search'
         21        FETCH_DIM_R                                      ~18     !4, 'order_id'
         22        SEND_VAL                                                 ~18
         23        SEND_VAR                                                 !2
         24        DO_ICALL                                         $19     
         25        ASSIGN                                                   !6, $19
   22    26      > JMPZ                                                     !6, ->30
         27    >   FETCH_DIM_R                                      ~23     !1, !6
         28        QM_ASSIGN                                        ~24     ~23
         29      > JMP                                                      ->31
         30    >   QM_ASSIGN                                        ~24     <array>
         31    >   FETCH_DIM_W                                      $21     !3, !5
         32        ASSIGN_DIM                                               $21, 'customer'
         33        OP_DATA                                                  ~24
   18    34      > JMP                                                      ->16
         35    >   FE_FREE                                                  $14
   25    36        INIT_FCALL                                               'print_r'
         37        SEND_VAR                                                 !3
         38        DO_ICALL                                                 
         39      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
178.36 ms | 1400 KiB | 23 Q