3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array1 = [ "bill_type" => "1", "bill_number" => "BIL-003", "order_number" => "ON-003", "items" => [ "track_inventory" => "0", "sku1" => "sku1", "name" => "Kidswear1" ] ]; $array2 = [ "bill_type" => "1", "bill_number" => "BIL-003", "order_number" => "ON-003", "items" => [ "track_inventory" => "0", "sku1" => "sku2", "name" => "Pant" ] ]; $array3 = [ "bill_type" => "1", "bill_number" => "BIL-002", "order_number" => "ON-002", "items" => [ "track_inventory" => "0", "sku1" => "sku3", "name" => "Pants" ] ]; $result = []; foreach ([$array1, $array2, $array3] as $row) { $key = $row['bill_number']; if (!isset($result[$key])) { $row['items'] = [$row['items']]; $result[$key] = $row; } else { $result[$key]['items'][] = $row['items']; } } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 27
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 27
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 21
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
filename:       /in/St3mq
function name:  (null)
number of ops:  32
compiled vars:  !0 = $array1, !1 = $array2, !2 = $array3, !3 = $result, !4 = $row, !5 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   14     1        ASSIGN                                                   !1, <array>
   25     2        ASSIGN                                                   !2, <array>
   36     3        ASSIGN                                                   !3, <array>
   37     4        INIT_ARRAY                                       ~10     !0
          5        ADD_ARRAY_ELEMENT                                ~10     !1
          6        ADD_ARRAY_ELEMENT                                ~10     !2
          7      > FE_RESET_R                                       $11     ~10, ->27
          8    > > FE_FETCH_R                                               $11, !4, ->27
   38     9    >   FETCH_DIM_R                                      ~12     !4, 'bill_number'
         10        ASSIGN                                                   !5, ~12
   39    11        ISSET_ISEMPTY_DIM_OBJ                         0  ~14     !3, !5
         12        BOOL_NOT                                         ~15     ~14
         13      > JMPZ                                                     ~15, ->21
   40    14    >   FETCH_DIM_R                                      ~17     !4, 'items'
         15        INIT_ARRAY                                       ~18     ~17
         16        ASSIGN_DIM                                               !4, 'items'
         17        OP_DATA                                                  ~18
   41    18        ASSIGN_DIM                                               !3, !5
         19        OP_DATA                                                  !4
   39    20      > JMP                                                      ->26
   43    21    >   FETCH_DIM_R                                      ~23     !4, 'items'
         22        FETCH_DIM_W                                      $20     !3, !5
         23        FETCH_DIM_W                                      $21     $20, 'items'
         24        ASSIGN_DIM                                               $21
         25        OP_DATA                                                  ~23
   37    26    > > JMP                                                      ->8
         27    >   FE_FREE                                                  $11
   46    28        INIT_FCALL                                               'var_export'
         29        SEND_VAR                                                 !3
         30        DO_ICALL                                                 
         31      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.81 ms | 1003 KiB | 14 Q