3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array( 0 => array( "id" => 3412341233214, "number" => 21000 ), 1 => array( "id" => 12121212121212, "number" => 18000 ), 2 => array( "id" => 12121212121212, "number" => 17000 ) ); $tmp = Array(); foreach($array as $obj) { if(!isset($tmp[$obj['id']])) { $tmp[$obj['id']] = array_merge(Array('number'=>1),$obj); continue; } $tmp[$obj['id']]['number'] += $obj['number']; } echo '<pre>'; print_r(array_values($tmp)); echo '</pre>';
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 = 16
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 16
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/UMJ4p
function name:  (null)
number of ops:  32
compiled vars:  !0 = $array, !1 = $tmp, !2 = $obj
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    >   FETCH_DIM_R                                      ~6      !2, 'id'
          5        ISSET_ISEMPTY_DIM_OBJ                         0  ~7      !1, ~6
          6        BOOL_NOT                                         ~8      ~7
          7      > JMPZ                                                     ~8, ->16
   22     8    >   FETCH_DIM_R                                      ~9      !2, 'id'
          9        INIT_FCALL                                               'array_merge'
         10        SEND_VAL                                                 <array>
         11        SEND_VAR                                                 !2
         12        DO_ICALL                                         $11     
         13        ASSIGN_DIM                                               !1, ~9
         14        OP_DATA                                                  $11
   23    15      > JMP                                                      ->3
   25    16    >   FETCH_DIM_R                                      ~12     !2, 'id'
         17        FETCH_DIM_R                                      ~15     !2, 'number'
         18        FETCH_DIM_RW                                     $13     !1, ~12
         19        ASSIGN_DIM_OP                +=               1          $13, 'number'
         20        OP_DATA                                                  ~15
   20    21      > JMP                                                      ->3
         22    >   FE_FREE                                                  $5
   28    23        ECHO                                                     '%3Cpre%3E'
   29    24        INIT_FCALL                                               'print_r'
         25        INIT_FCALL                                               'array_values'
         26        SEND_VAR                                                 !1
         27        DO_ICALL                                         $16     
         28        SEND_VAR                                                 $16
         29        DO_ICALL                                                 
   30    30        ECHO                                                     '%3C%2Fpre%3E'
         31      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.28 ms | 1005 KiB | 16 Q