3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ ['city' => 'NewYork', 'cash' => '1000'], ['city' => 'Philadelphia', 'cash' => '2300'], ['city' => 'NewYork', 'cash' => '2000'] ]; var_export( array_reduce( $array, function($result, $row) { static $ref; if (!isset($ref[$row['city']])) { $ref[$row['city']] = $row; $result[] = &$ref[$row['city']]; } else { $ref[$row['city']]['cash'] += $row['cash']; } return $result; } ) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hp1Te
function name:  (null)
number of ops:  10
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    9     1        INIT_FCALL                                               'var_export'
   10     2        INIT_FCALL                                               'array_reduce'
   11     3        SEND_VAR                                                 !0
   12     4        DECLARE_LAMBDA_FUNCTION                          ~2      [0]
   21     5        SEND_VAL                                                 ~2
   10     6        DO_ICALL                                         $3      
   21     7        SEND_VAR                                                 $3
    9     8        DO_ICALL                                                 
   23     9      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 16
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hp1Te
function name:  {closure}
number of ops:  23
compiled vars:  !0 = $result, !1 = $row, !2 = $ref
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   13     2        BIND_STATIC                                              !2
   14     3        FETCH_DIM_R                                      ~3      !1, 'city'
          4        ISSET_ISEMPTY_DIM_OBJ                         0  ~4      !2, ~3
          5        BOOL_NOT                                         ~5      ~4
          6      > JMPZ                                                     ~5, ->16
   15     7    >   FETCH_DIM_R                                      ~6      !1, 'city'
          8        ASSIGN_DIM                                               !2, ~6
          9        OP_DATA                                                  !1
   16    10        FETCH_DIM_R                                      ~9      !1, 'city'
         11        FETCH_DIM_W                                      $10     !2, ~9
         12        MAKE_REF                                         $11     $10
         13        FETCH_DIM_W                                      $8      !0
         14        ASSIGN_REF                                               $8, $11
   14    15      > JMP                                                      ->21
   18    16    >   FETCH_DIM_R                                      ~13     !1, 'city'
         17        FETCH_DIM_R                                      ~16     !1, 'cash'
         18        FETCH_DIM_RW                                     $14     !2, ~13
         19        ASSIGN_DIM_OP                +=               1          $14, 'cash'
         20        OP_DATA                                                  ~16
   20    21    > > RETURN                                                   !0
   21    22*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137.13 ms | 1000 KiB | 15 Q