3v4l.org

run code in 500+ PHP versions simultaneously
<?php $arr = Array ( '0' => Array ( 'number' => 2, 'name' => 'ABC' ), '1' => Array ( 'number' => 3, 'name' => 'ABC' ), '2' => Array ( 'number' => 1, 'name' => 'XYZ' ), '3' => Array ( 'number' => 2, 'name' => 'XYZ' ) ); $res = []; array_map(function($v) use (&$res){ array_key_exists($v['name'], $res) ? ($res[$v['name']]['number'] = $res[$v['name']]['number'].','.$v['number']) : ($res[$v['name']] = ['number' => $v['number'],'name' => $v['name']]) ; }, $arr); $res = array_values($res); echo '<pre>'; print_r($res);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lEDHH
function name:  (null)
number of ops:  17
compiled vars:  !0 = $arr, !1 = $res
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   29     1        ASSIGN                                                       !1, <array>
   30     2        INIT_FCALL                                                   'array_map'
          3        DECLARE_LAMBDA_FUNCTION                              ~4      [0]
          4        BIND_LEXICAL                                                 ~4, !1
   36     5        SEND_VAL                                                     ~4
          6        SEND_VAR                                                     !0
   30     7        DO_ICALL                                                     
   37     8        INIT_FCALL                                                   'array_values'
          9        SEND_VAR                                                     !1
         10        DO_ICALL                                             $6      
         11        ASSIGN                                                       !1, $6
   38    12        ECHO                                                         '%3Cpre%3E'
   39    13        INIT_FCALL                                                   'print_r'
         14        SEND_VAR                                                     !1
         15        DO_ICALL                                                     
         16      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 17
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lEDHH
function name:  {closure:/in/lEDHH:30}
number of ops:  27
compiled vars:  !0 = $v, !1 = $res
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   30     0  E >   RECV                                                 !0      
          1        BIND_STATIC                                                  !1
   31     2        FETCH_DIM_R                                          ~2      !0, 'name'
          3        ARRAY_KEY_EXISTS                                             ~2, !1
          4      > JMPZ                                                         ~3, ->17
   32     5    >   FETCH_DIM_R                                          ~4      !0, 'name'
          6        FETCH_DIM_R                                          ~7      !0, 'name'
          7        FETCH_DIM_R                                          ~8      !1, ~7
          8        FETCH_DIM_R                                          ~9      ~8, 'number'
          9        CONCAT                                               ~10     ~9, '%2C'
         10        FETCH_DIM_R                                          ~11     !0, 'number'
         11        CONCAT                                               ~12     ~10, ~11
         12        FETCH_DIM_W                                          $5      !1, ~4
         13        ASSIGN_DIM                                           ~6      $5, 'number'
         14        OP_DATA                                                      ~12
         15        QM_ASSIGN                                            ~13     ~6
         16      > JMP                                                          ->25
   34    17    >   FETCH_DIM_R                                          ~14     !0, 'name'
         18        FETCH_DIM_R                                          ~16     !0, 'number'
         19        INIT_ARRAY                                           ~17     ~16, 'number'
         20        FETCH_DIM_R                                          ~18     !0, 'name'
         21        ADD_ARRAY_ELEMENT                                    ~17     ~18, 'name'
         22        ASSIGN_DIM                                           ~15     !1, ~14
         23        OP_DATA                                                      ~17
         24        QM_ASSIGN                                            ~13     ~15
         25    >   FREE                                                         ~13
   36    26      > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
200.58 ms | 2368 KiB | 16 Q