3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = array ( 0 => array ( 'name' => 'Viettel', 'data' => array ( 0 => '1559881644000,500' ), ), 1 => array ( 'name' => 'FPT', 'data' => array ( 0 => '1559994465000,172' ), ), 2 => array ( 'name' => 'MobiFone', 'data' => array ( 0 => '1559997314000,11164' ), ), 3 => array ( 'name' => 'Vietnamobile', 'data' => array ( 0 => '1559993699000,1246' ), ), 4 => array ( 'name' => 'Viettel', 'data' => array ( 0 => '1560000096000,47886' ), ), 5 => array ( 'name' => 'VinaPhone', 'data' => array ( 0 => '1559997553000,11132' ), ), 6 => array ( 'name' => 'VNPT', 'data' => array ( 0 => '1559993066000,84' ), ) ); $result = array(); foreach ($data as $itemData) { if (($k = array_search($itemData['name'], array_column($result, 'name'))) !== false) { $result[$k]['data'] = array_merge($result[$k]['data'], $itemData['data']); } else $result[] = $itemData; } print_r($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 30
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 30
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 27
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
filename:       /in/jNr0X
function name:  (null)
number of ops:  35
compiled vars:  !0 = $data, !1 = $result, !2 = $itemData, !3 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   68     1        ASSIGN                                                   !1, <array>
   69     2      > FE_RESET_R                                       $6      !0, ->30
          3    > > FE_FETCH_R                                               $6, !2, ->30
   70     4    >   INIT_FCALL                                               'array_search'
          5        FETCH_DIM_R                                      ~7      !2, 'name'
          6        SEND_VAL                                                 ~7
          7        INIT_FCALL                                               'array_column'
          8        SEND_VAR                                                 !1
          9        SEND_VAL                                                 'name'
         10        DO_ICALL                                         $8      
         11        SEND_VAR                                                 $8
         12        DO_ICALL                                         $9      
         13        ASSIGN                                           ~10     !3, $9
         14        TYPE_CHECK                                  1018          ~10
         15      > JMPZ                                                     ~11, ->27
   71    16    >   INIT_FCALL                                               'array_merge'
         17        FETCH_DIM_R                                      ~14     !1, !3
         18        FETCH_DIM_R                                      ~15     ~14, 'data'
         19        SEND_VAL                                                 ~15
         20        FETCH_DIM_R                                      ~16     !2, 'data'
         21        SEND_VAL                                                 ~16
         22        DO_ICALL                                         $17     
         23        FETCH_DIM_W                                      $12     !1, !3
         24        ASSIGN_DIM                                               $12, 'data'
         25        OP_DATA                                                  $17
   70    26      > JMP                                                      ->29
   73    27    >   ASSIGN_DIM                                               !1
         28        OP_DATA                                                  !2
   69    29    > > JMP                                                      ->3
         30    >   FE_FREE                                                  $6
   75    31        INIT_FCALL                                               'print_r'
         32        SEND_VAR                                                 !1
         33        DO_ICALL                                                 
         34      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.52 ms | 1002 KiB | 17 Q