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 [ 'product_code' => $code, 'cha_sty_id' => $id, 'product_code' => $result[$code]['product_code'], 'product_name' => $result[$code]['product_name'], 'chs_name' => $result[$code][strtolower($id)][] ] ); var_export(array_values($result));
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 26
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 26
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
filename:       /in/P1GV4
function name:  (null)
number of ops:  34
compiled vars:  !0 = $array, !1 = $result, !2 = $code, !3 = $id
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   53     1        ASSIGN                                                   !1, <array>
   55     2      > FE_RESET_R                                       $6      !0, ->26
          3    > > FE_FETCH_R                                               $6, $7, ->26
   58     4    >   FETCH_LIST_R                                     $8      $7, 'product_code'
          5        ASSIGN                                                   !2, $8
   59     6        FETCH_LIST_R                                     $10     $7, 'cha_sty_id'
          7        ASSIGN                                                   !3, $10
   60     8        FETCH_LIST_R                                     $12     $7, 'product_code'
          9        FETCH_DIM_W                                      $13     !1, !2
         10        ASSIGN_DIM                                               $13, 'product_code'
         11        OP_DATA                                                  $12
   61    12        FETCH_LIST_R                                     $15     $7, 'product_name'
         13        FETCH_DIM_W                                      $16     !1, !2
         14        ASSIGN_DIM                                               $16, 'product_name'
         15        OP_DATA                                                  $15
   62    16        FETCH_LIST_R                                     $18     $7, 'chs_name'
         17        INIT_FCALL                                               'strtolower'
         18        SEND_VAR                                                 !3
         19        DO_ICALL                                         $20     
         20        FETCH_DIM_W                                      $19     !1, !2
         21        FETCH_DIM_W                                      $21     $19, $20
         22        ASSIGN_DIM                                               $21
         23        OP_DATA                                                  $18
         24        FREE                                                     $7
   55    25      > JMP                                                      ->3
         26    >   FE_FREE                                                  $6
   65    27        INIT_FCALL                                               'var_export'
         28        INIT_FCALL                                               'array_values'
         29        SEND_VAR                                                 !1
         30        DO_ICALL                                         $23     
         31        SEND_VAR                                                 $23
         32        DO_ICALL                                                 
         33      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.02 ms | 1001 KiB | 16 Q