3v4l.org

run code in 500+ 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" ] ]; var_export( array_values( array_reduce( $array, function($result, $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']; return $result; }, [] ) ) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SRKUu
function name:  (null)
number of ops:  14
compiled vars:  !0 = $array
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                       !0, <array>
   53     1        INIT_FCALL                                                   'var_export'
   54     2        INIT_FCALL                                                   'array_values'
   55     3        INIT_FCALL                                                   'array_reduce'
   56     4        SEND_VAR                                                     !0
   57     5        DECLARE_LAMBDA_FUNCTION                              ~2      [0]
   62     6        SEND_VAL                                                     ~2
   63     7        SEND_VAL                                                     <array>
   55     8        DO_ICALL                                             $3      
   63     9        SEND_VAR                                                     $3
   54    10        DO_ICALL                                             $4      
   63    11        SEND_VAR                                                     $4
   53    12        DO_ICALL                                                     
   66    13      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SRKUu
function name:  {closure:/in/SRKUu:57}
number of ops:  24
compiled vars:  !0 = $result, !1 = $row
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   57     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   58     2        FETCH_DIM_R                                          ~2      !1, 'product_code'
          3        FETCH_DIM_R                                          ~5      !1, 'product_code'
          4        FETCH_DIM_W                                          $3      !0, ~2
          5        ASSIGN_DIM                                                   $3, 'product_code'
          6        OP_DATA                                                      ~5
   59     7        FETCH_DIM_R                                          ~6      !1, 'product_code'
          8        FETCH_DIM_R                                          ~9      !1, 'product_name'
          9        FETCH_DIM_W                                          $7      !0, ~6
         10        ASSIGN_DIM                                                   $7, 'product_name'
         11        OP_DATA                                                      ~9
   60    12        FETCH_DIM_R                                          ~10     !1, 'product_code'
         13        INIT_FCALL                                                   'strtolower'
         14        FETCH_DIM_R                                          ~12     !1, 'cha_sty_id'
         15        SEND_VAL                                                     ~12
         16        DO_ICALL                                             $13     
         17        FETCH_DIM_R                                          ~16     !1, 'chs_name'
         18        FETCH_DIM_W                                          $11     !0, ~10
         19        FETCH_DIM_W                                          $14     $11, $13
         20        ASSIGN_DIM                                                   $14
         21        OP_DATA                                                      ~16
   61    22      > RETURN                                                       !0
   62    23*     > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
166.38 ms | 1922 KiB | 17 Q