3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ ['city' => 'NewYork', 'cash' => '1000'], ['city' => 'Philadelphia', 'cash' => '2300'], ['city' => 'NewYork', 'cash' => '2000'] ]; foreach ($array as $row) { $result[$row['city']] = [ 'city' => $row['city'], 'cash' => ($result[$row['city']]['cash'] ?? 0) + $row['cash'] ]; } var_export(array_values($result));
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 17
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 17
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/0DUhM
function name:  (null)
number of ops:  25
compiled vars:  !0 = $array, !1 = $row, !2 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    9     1      > FE_RESET_R                                       $4      !0, ->17
          2    > > FE_FETCH_R                                               $4, !1, ->17
   10     3    >   FETCH_DIM_R                                      ~5      !1, 'city'
   11     4        FETCH_DIM_R                                      ~7      !1, 'city'
          5        INIT_ARRAY                                       ~8      ~7, 'city'
   12     6        FETCH_DIM_R                                      ~9      !1, 'city'
          7        FETCH_DIM_IS                                     ~10     !2, ~9
          8        FETCH_DIM_IS                                     ~11     ~10, 'cash'
          9        COALESCE                                         ~12     ~11
         10        QM_ASSIGN                                        ~12     0
         11        FETCH_DIM_R                                      ~13     !1, 'cash'
         12        ADD                                              ~14     ~12, ~13
         13        ADD_ARRAY_ELEMENT                                ~8      ~14, 'cash'
   10    14        ASSIGN_DIM                                               !2, ~5
   12    15        OP_DATA                                                  ~8
    9    16      > JMP                                                      ->2
         17    >   FE_FREE                                                  $4
   15    18        INIT_FCALL                                               'var_export'
         19        INIT_FCALL                                               'array_values'
         20        SEND_VAR                                                 !2
         21        DO_ICALL                                         $15     
         22        SEND_VAR                                                 $15
         23        DO_ICALL                                                 
         24      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.19 ms | 1006 KiB | 15 Q