3v4l.org

run code in 500+ PHP versions simultaneously
<?php $array = [ 0 => [ "product_code" => "67021687", "product_name" => "Spaces", "cha_sty_id" => "PUSH", "chs_name" => "WF" ], 1 => [ "product_code" => "67021687", "product_name" => "Spaces", "cha_sty_id" => "PUSH", "chs_name" => "WFR" ], 2 => [ "product_code" => "67021687", "product_name" => "Spaces", "cha_sty_id" => "PUSH", "chs_name" => "STK Food" ], 3 => [ "product_code" => "67021687", "product_name" => "Spaces", "cha_sty_id" => "PULL", "chs_name" => "4 Stars" ], 4 => [ "product_code" => "67021687", "product_name" => "Spaces", "cha_sty_id" => "PULL", "chs_name" => "5 Stars" ], 5 => [ "product_code" => "67021687", "product_name" => "Spaces", "cha_sty_id" => "PULL", "chs_name" => "Modern Thai" ], 6 => [ "product_code" => "67021687", "product_name" => "Spaces", "cha_sty_id" => "PULL", "chs_name" => "BBQ Buffet" ], 7 => [ "product_code" => "67021687", "product_name" => "Spaces", "cha_sty_id" => "PULL", "chs_name" => "Chinese" ] ]; $res = []; array_walk($array, function($v, $k) use (&$res){ if(in_array($v['product_code'], array_column($res, 'product_code'))){ array_push($res[$v['product_code']]["push"], $v['chs_name']); array_push($res[$v['product_code']]["pull"], $v['chs_name']); }else{ $res[$v['product_code']] = [ "product_code" => $v['product_code'], "product_name" => $v['product_name'], "push" => [$v['chs_name']], "pull" => [$v['chs_name']] ]; } }); echo '<pre>'; print_r(array_values($res));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jduqg
function name:  (null)
number of ops:  16
compiled vars:  !0 = $array, !1 = $res
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                       !0, <array>
   53     1        ASSIGN                                                       !1, <array>
   54     2        INIT_FCALL                                                   'array_walk'
          3        SEND_REF                                                     !0
          4        DECLARE_LAMBDA_FUNCTION                              ~4      [0]
          5        BIND_LEXICAL                                                 ~4, !1
   66     6        SEND_VAL                                                     ~4
   54     7        DO_ICALL                                                     
   68     8        ECHO                                                         '%3Cpre%3E'
   69     9        INIT_FCALL                                                   'print_r'
         10        INIT_FCALL                                                   'array_values'
         11        SEND_VAR                                                     !1
         12        DO_ICALL                                             $6      
         13        SEND_VAR                                                     $6
         14        DO_ICALL                                                     
         15      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 27
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jduqg
function name:  {closure:/in/jduqg:54}
number of ops:  41
compiled vars:  !0 = $v, !1 = $k, !2 = $res
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   54     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        BIND_STATIC                                                  !2
   55     3        FETCH_DIM_R                                          ~3      !0, 'product_code'
          4        INIT_FCALL                                                   'array_column'
          5        SEND_VAR                                                     !2
          6        SEND_VAL                                                     'product_code'
          7        DO_ICALL                                             $4      
          8        FRAMELESS_ICALL_2                in_array            ~5      ~3, $4
          9      > JMPZ                                                         ~5, ->27
   56    10    >   INIT_FCALL                                                   'array_push'
         11        FETCH_DIM_R                                          ~6      !0, 'product_code'
         12        FETCH_DIM_W                                          $7      !2, ~6
         13        FETCH_DIM_W                                          $8      $7, 'push'
         14        SEND_REF                                                     $8
         15        FETCH_DIM_R                                          ~9      !0, 'chs_name'
         16        SEND_VAL                                                     ~9
         17        DO_ICALL                                                     
   57    18        INIT_FCALL                                                   'array_push'
         19        FETCH_DIM_R                                          ~11     !0, 'product_code'
         20        FETCH_DIM_W                                          $12     !2, ~11
         21        FETCH_DIM_W                                          $13     $12, 'pull'
         22        SEND_REF                                                     $13
         23        FETCH_DIM_R                                          ~14     !0, 'chs_name'
         24        SEND_VAL                                                     ~14
         25        DO_ICALL                                                     
   55    26      > JMP                                                          ->40
   59    27    >   FETCH_DIM_R                                          ~16     !0, 'product_code'
   60    28        FETCH_DIM_R                                          ~18     !0, 'product_code'
         29        INIT_ARRAY                                           ~19     ~18, 'product_code'
   61    30        FETCH_DIM_R                                          ~20     !0, 'product_name'
         31        ADD_ARRAY_ELEMENT                                    ~19     ~20, 'product_name'
   62    32        FETCH_DIM_R                                          ~21     !0, 'chs_name'
         33        INIT_ARRAY                                           ~22     ~21
         34        ADD_ARRAY_ELEMENT                                    ~19     ~22, 'push'
   63    35        FETCH_DIM_R                                          ~23     !0, 'chs_name'
         36        INIT_ARRAY                                           ~24     ~23
         37        ADD_ARRAY_ELEMENT                                    ~19     ~24, 'pull'
   59    38        ASSIGN_DIM                                                   !2, ~16
   63    39        OP_DATA                                                      ~19
   66    40    > > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
160.28 ms | 2313 KiB | 18 Q