3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array1 = [ (object) [ 'expense_id' => 475, 'expense_name' => 'DRAY', 'expense_unit_cost' => 270.00 ], (object) [ 'expense_id' => 476, 'expense_name' => 'FUEL', 'expense_unit_cost' => 32.40 ], ]; $array2 = [ (object) [ 'waybill_id' => 20005044, 'expense_id' => 475, 'tax_select' => 'tax1', 'tax_id' => 1, 'tax_name' => 'GST 5%', 'tax_no' => null, 'tax_value' => 13.5000 ], (object) [ 'waybill_id' => 20005044, 'expense_id' => 475, 'tax_select' => 'tax2', 'tax_id' => 2, 'tax_name' => 'QST 9.975%', 'tax_no' => null, 'tax_value' => 26.9325 ], (object) [ 'waybill_id' => 20005044, 'expense_id' => 476, 'tax_select' => 'tax1', 'tax_id' => 1, 'tax_name' => 'GST 5%', 'tax_no' => null, 'tax_value' => 1.6200 ], (object) [ 'waybill_id' => 20005044, 'expense_id' => 476, 'tax_select' => 'tax2', 'tax_id' => 2, 'tax_name' => 'QST 9.975%', 'tax_no' => null, 'tax_value' => 3.2319 ], ]; $array1 = array_column($array1, null, 'expense_id'); foreach ($array2 as $obj) { if (isset($array1[$obj->expense_id])) { $array1[$obj->expense_id]->expense_taxes[] = $obj; } } var_export(array_values($array1));
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 21, Position 2 = 31
Branch analysis from position: 21
2 jumps found. (Code = 78) Position 1 = 22, Position 2 = 31
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 30
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
Branch analysis from position: 30
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
filename:       /in/WnrlU
function name:  (null)
number of ops:  39
compiled vars:  !0 = $array1, !1 = $array2, !2 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   CAST                                          8  ~3      <array>
          1        INIT_ARRAY                                       ~4      ~3
   10     2        CAST                                          8  ~5      <array>
          3        ADD_ARRAY_ELEMENT                                ~4      ~5
    3     4        ASSIGN                                                   !0, ~4
   18     5        CAST                                          8  ~7      <array>
          6        INIT_ARRAY                                       ~8      ~7
   27     7        CAST                                          8  ~9      <array>
          8        ADD_ARRAY_ELEMENT                                ~8      ~9
   36     9        CAST                                          8  ~10     <array>
         10        ADD_ARRAY_ELEMENT                                ~8      ~10
   45    11        CAST                                          8  ~11     <array>
         12        ADD_ARRAY_ELEMENT                                ~8      ~11
   16    13        ASSIGN                                                   !1, ~8
   55    14        INIT_FCALL                                               'array_column'
         15        SEND_VAR                                                 !0
         16        SEND_VAL                                                 null
         17        SEND_VAL                                                 'expense_id'
         18        DO_ICALL                                         $13     
         19        ASSIGN                                                   !0, $13
   56    20      > FE_RESET_R                                       $15     !1, ->31
         21    > > FE_FETCH_R                                               $15, !2, ->31
   57    22    >   FETCH_OBJ_R                                      ~16     !2, 'expense_id'
         23        ISSET_ISEMPTY_DIM_OBJ                         0          !0, ~16
         24      > JMPZ                                                     ~17, ->30
   58    25    >   FETCH_OBJ_R                                      ~18     !2, 'expense_id'
         26        FETCH_DIM_W                                      $19     !0, ~18
         27        FETCH_OBJ_W                                      $20     $19, 'expense_taxes'
         28        ASSIGN_DIM                                               $20
         29        OP_DATA                                                  !2
   56    30    > > JMP                                                      ->21
         31    >   FE_FREE                                                  $15
   61    32        INIT_FCALL                                               'var_export'
         33        INIT_FCALL                                               'array_values'
         34        SEND_VAR                                                 !0
         35        DO_ICALL                                         $22     
         36        SEND_VAR                                                 $22
         37        DO_ICALL                                                 
         38      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
126.53 ms | 1405 KiB | 19 Q