3v4l.org

run code in 300+ PHP versions simultaneously
<?php $user = []; $arr = [ 'chatduration' => '124.502','username' => 'bhavin']; foreach($arr as $record){ if (array_key_exists($user[$record['username']],$record)) { $user[$record['username']] = $user[$record['username']] + $record['chatduration']; } else { $user[] = [$record['username']=>$record['chatduration']]; } } print_r($arr);
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 = 21
Branch analysis from position: 21
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/sYPbA
function name:  (null)
number of ops:  27
compiled vars:  !0 = $user, !1 = $arr, !2 = $record
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    3     1        ASSIGN                                                   !1, <array>
    5     2      > FE_RESET_R                                       $5      !1, ->22
          3    > > FE_FETCH_R                                               $5, !2, ->22
    7     4    >   FETCH_DIM_R                                      ~6      !2, 'username'
          5        FETCH_DIM_R                                      ~7      !0, ~6
          6        ARRAY_KEY_EXISTS                                         ~7, !2
          7      > JMPZ                                                     ~8, ->16
    9     8    >   FETCH_DIM_R                                      ~9      !2, 'username'
          9        FETCH_DIM_R                                      ~11     !2, 'username'
         10        FETCH_DIM_R                                      ~12     !0, ~11
         11        FETCH_DIM_R                                      ~13     !2, 'chatduration'
         12        ADD                                              ~14     ~12, ~13
         13        ASSIGN_DIM                                               !0, ~9
         14        OP_DATA                                                  ~14
         15      > JMP                                                      ->21
   13    16    >   FETCH_DIM_R                                      ~16     !2, 'username'
         17        FETCH_DIM_R                                      ~17     !2, 'chatduration'
         18        INIT_ARRAY                                       ~18     ~17, ~16
         19        ASSIGN_DIM                                               !0
         20        OP_DATA                                                  ~18
    5    21    > > JMP                                                      ->3
         22    >   FE_FREE                                                  $5
   18    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:
174.65 ms | 1396 KiB | 15 Q