3v4l.org

run code in 300+ PHP versions simultaneously
<?php $user = []; $arr = [ 'chatduration' => '124.502','username' => 'bhavin']; print_r($arr); die(); 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
1 jumps found. (Code = 79) Position 1 = -2
filename:       /in/irdVW
function name:  (null)
number of ops:  31
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>
    4     2        INIT_FCALL                                               'print_r'
          3        SEND_VAR                                                 !1
          4        DO_ICALL                                                 
    5     5      > EXIT                                                     
    6     6*       FE_RESET_R                                       $6      !1, ->26
          7*       FE_FETCH_R                                               $6, !2, ->26
    8     8*       FETCH_DIM_R                                      ~7      !2, 'username'
          9*       FETCH_DIM_R                                      ~8      !0, ~7
         10*       ARRAY_KEY_EXISTS                                         ~8, !2
         11*       JMPZ                                                     ~9, ->20
   10    12*       FETCH_DIM_R                                      ~10     !2, 'username'
         13*       FETCH_DIM_R                                      ~12     !2, 'username'
         14*       FETCH_DIM_R                                      ~13     !0, ~12
         15*       FETCH_DIM_R                                      ~14     !2, 'chatduration'
         16*       ADD                                              ~15     ~13, ~14
         17*       ASSIGN_DIM                                               !0, ~10
         18*       OP_DATA                                                  ~15
         19*       JMP                                                      ->25
   14    20*       FETCH_DIM_R                                      ~17     !2, 'username'
         21*       FETCH_DIM_R                                      ~18     !2, 'chatduration'
         22*       INIT_ARRAY                                       ~19     ~18, ~17
         23*       ASSIGN_DIM                                               !0
         24*       OP_DATA                                                  ~19
    6    25*       JMP                                                      ->7
         26*       FE_FREE                                                  $6
   19    27*       INIT_FCALL                                               'print_r'
         28*       SEND_VAR                                                 !1
         29*       DO_ICALL                                                 
         30*     > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
177.86 ms | 1395 KiB | 15 Q