3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = array( array( 'pageviews' => 233, 'pagepath' => 111 ), array( 'pageviews' => 100, 'pagepath' => 111 ), array( 'pageviews' => 300, 'pagepath' => 222 ) ); $grouped = []; foreach($data as $subarr) { if(isset($grouped[((object) $subarr)->pagepath])) { $grouped[((object) $subarr)->pagepath] += ((object) $subarr)->pageviews; continue; } $grouped[((object) $subarr)->pagepath] = ((object) $subarr)->pageviews; } print_r($grouped);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 22
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 22
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 15
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
filename:       /in/u8nf8
function name:  (null)
number of ops:  27
compiled vars:  !0 = $data, !1 = $grouped, !2 = $subarr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   18     1        ASSIGN                                                   !1, <array>
   20     2      > FE_RESET_R                                       $5      !0, ->22
          3    > > FE_FETCH_R                                               $5, !2, ->22
   21     4    >   CAST                                          8  ~6      !2
          5        FETCH_OBJ_R                                      ~7      ~6, 'pagepath'
          6        ISSET_ISEMPTY_DIM_OBJ                         0          !1, ~7
          7      > JMPZ                                                     ~8, ->15
   22     8    >   CAST                                          8  ~9      !2
          9        FETCH_OBJ_R                                      ~10     ~9, 'pagepath'
         10        CAST                                          8  ~12     !2
         11        FETCH_OBJ_R                                      ~13     ~12, 'pageviews'
         12        ASSIGN_DIM_OP                +=               1          !1, ~10
         13        OP_DATA                                                  ~13
   23    14      > JMP                                                      ->3
   25    15    >   CAST                                          8  ~14     !2
         16        FETCH_OBJ_R                                      ~15     ~14, 'pagepath'
         17        CAST                                          8  ~17     !2
         18        FETCH_OBJ_R                                      ~18     ~17, 'pageviews'
         19        ASSIGN_DIM                                               !1, ~15
         20        OP_DATA                                                  ~18
   20    21      > JMP                                                      ->3
         22    >   FE_FREE                                                  $5
   28    23        INIT_FCALL                                               'print_r'
         24        SEND_VAR                                                 !1
         25        DO_ICALL                                                 
         26      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
319.57 ms | 1016 KiB | 14 Q