3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ [ "product_code" => "67021687", "product_name" => "Spaces", "cha_sty_id" => "PUSH", "chs_name" => "WF" ], [ "product_code" => "67021687", "product_name" => "Spaces", "cha_sty_id" => "PUSH", "chs_name" => "WFR" ], [ "product_code" => "67021687", "product_name" => "Spaces", "cha_sty_id" => "PUSH", "chs_name" => "STK Food" ], [ "product_code" => "67021687", "product_name" => "Spaces", "cha_sty_id" => "PULL", "chs_name" => "4 Stars" ], [ "product_code" => "67021687", "product_name" => "Spaces", "cha_sty_id" => "PULL", "chs_name" => "5 Stars" ], [ "product_code" => "67021687", "product_name" => "Spaces", "cha_sty_id" => "PULL", "chs_name" => "Modern Thai" ], [ "product_code" => "67021687", "product_name" => "Spaces", "cha_sty_id" => "PULL", "chs_name" => "BBQ Buffet" ], [ "product_code" => "67021687", "product_name" => "Spaces", "cha_sty_id" => "PULL", "chs_name" => "Chinese" ] ]; $result = []; foreach ($array as $row) { $result[$row['product_code']]['product_code'] = $row['product_code']; $result[$row['product_code']]['product_name'] = $row['product_name']; $result[$row['product_code']][strtolower($row['cha_sty_id'])][] = $row['chs_name']; } var_export(array_values($result));
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 25
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 25
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
filename:       /in/HJdBW
function name:  (null)
number of ops:  33
compiled vars:  !0 = $array, !1 = $result, !2 = $row
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   53     1        ASSIGN                                                   !1, <array>
   54     2      > FE_RESET_R                                       $5      !0, ->25
          3    > > FE_FETCH_R                                               $5, !2, ->25
   55     4    >   FETCH_DIM_R                                      ~6      !2, 'product_code'
          5        FETCH_DIM_R                                      ~9      !2, 'product_code'
          6        FETCH_DIM_W                                      $7      !1, ~6
          7        ASSIGN_DIM                                               $7, 'product_code'
          8        OP_DATA                                                  ~9
   56     9        FETCH_DIM_R                                      ~10     !2, 'product_code'
         10        FETCH_DIM_R                                      ~13     !2, 'product_name'
         11        FETCH_DIM_W                                      $11     !1, ~10
         12        ASSIGN_DIM                                               $11, 'product_name'
         13        OP_DATA                                                  ~13
   57    14        FETCH_DIM_R                                      ~14     !2, 'product_code'
         15        INIT_FCALL                                               'strtolower'
         16        FETCH_DIM_R                                      ~16     !2, 'cha_sty_id'
         17        SEND_VAL                                                 ~16
         18        DO_ICALL                                         $17     
         19        FETCH_DIM_R                                      ~20     !2, 'chs_name'
         20        FETCH_DIM_W                                      $15     !1, ~14
         21        FETCH_DIM_W                                      $18     $15, $17
         22        ASSIGN_DIM                                               $18
         23        OP_DATA                                                  ~20
   54    24      > JMP                                                      ->3
         25    >   FE_FREE                                                  $5
   59    26        INIT_FCALL                                               'var_export'
         27        INIT_FCALL                                               'array_values'
         28        SEND_VAR                                                 !1
         29        DO_ICALL                                         $21     
         30        SEND_VAR                                                 $21
         31        DO_ICALL                                                 
         32      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139.11 ms | 1001 KiB | 16 Q