3v4l.org

run code in 500+ PHP versions simultaneously
<?php // Capture the list of taste observations across analyses and phases of analysis $taste_observations = array(); // Temporary test data for Stack Overflow Question $taste_observations[] = [ 'analyst' => 'Ken', 'phase' => 'Entrance', 'taste' => 'Sweet', 'intensity' => 1 ]; $taste_observations[] = [ 'analyst' => 'Ken', 'phase' => 'Entrance', 'taste' => 'Spicy', 'intensity' => 1 ]; $taste_observations[] = [ 'analyst' => 'Ken', 'phase' => 'Center', 'taste' => 'Sweet', 'intensity' => 2 ]; $taste_observations[] = [ 'analyst' => 'Bob', 'phase' => 'Entrance', 'taste' => 'Savory', 'intensity' => 1 ]; $taste_observations[] = [ 'analyst' => 'Bob', 'phase' => 'After', 'taste' => 'Sweet', 'intensity' => 2, ]; $taste_summary = []; foreach($taste_observations as $taste_observation) { $taste_summary[$taste_observation['taste']] = [ 'taste' => $taste_observation['taste'], 'count' => 1 + ($taste_summary[$taste_observation['taste']]['count'] ?? 0), 'max' => max($taste_summary[$taste_observation['taste']]['max'] ?? 0, $taste_observation['intensity']), 'sum' => $taste_observation['intensity'] + ($taste_summary[$taste_observation['taste']]['sum'] ?? 0) ]; } ksort($taste_summary); $taste_summary = array_values($taste_summary); print_r($taste_summary);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 43
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 43
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 43
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 43
filename:       /in/GTZPD
function name:  (null)
number of ops:  55
compiled vars:  !0 = $taste_observations, !1 = $taste_summary, !2 = $taste_observation
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                       !0, <array>
    6     1        ASSIGN_DIM                                                   !0
    7     2        OP_DATA                                                      <array>
   12     3        ASSIGN_DIM                                                   !0
   13     4        OP_DATA                                                      <array>
   18     5        ASSIGN_DIM                                                   !0
   19     6        OP_DATA                                                      <array>
   24     7        ASSIGN_DIM                                                   !0
   25     8        OP_DATA                                                      <array>
   30     9        ASSIGN_DIM                                                   !0
   31    10        OP_DATA                                                      <array>
   37    11        ASSIGN                                                       !1, <array>
   38    12      > FE_RESET_R                                           $10     !0, ->43
         13    > > FE_FETCH_R                                                   $10, !2, ->43
   39    14    >   FETCH_DIM_R                                          ~11     !2, 'taste'
   40    15        FETCH_DIM_R                                          ~13     !2, 'taste'
         16        INIT_ARRAY                                           ~14     ~13, 'taste'
   41    17        FETCH_DIM_R                                          ~15     !2, 'taste'
         18        FETCH_DIM_IS                                         ~16     !1, ~15
         19        FETCH_DIM_IS                                         ~17     ~16, 'count'
         20        COALESCE                                             ~18     ~17
         21        QM_ASSIGN                                            ~18     0
         22        ADD                                                  ~19     1, ~18
         23        ADD_ARRAY_ELEMENT                                    ~14     ~19, 'count'
   42    24        FETCH_DIM_R                                          ~20     !2, 'taste'
         25        FETCH_DIM_IS                                         ~21     !1, ~20
         26        FETCH_DIM_IS                                         ~22     ~21, 'max'
         27        COALESCE                                             ~23     ~22
         28        QM_ASSIGN                                            ~23     0
         29        FETCH_DIM_R                                          ~24     !2, 'intensity'
         30        FRAMELESS_ICALL_2                max                 ~25     ~23, ~24
         31        ADD_ARRAY_ELEMENT                                    ~14     ~25, 'max'
   43    32        FETCH_DIM_R                                          ~26     !2, 'intensity'
         33        FETCH_DIM_R                                          ~27     !2, 'taste'
         34        FETCH_DIM_IS                                         ~28     !1, ~27
         35        FETCH_DIM_IS                                         ~29     ~28, 'sum'
         36        COALESCE                                             ~30     ~29
         37        QM_ASSIGN                                            ~30     0
         38        ADD                                                  ~31     ~26, ~30
         39        ADD_ARRAY_ELEMENT                                    ~14     ~31, 'sum'
   39    40        ASSIGN_DIM                                                   !1, ~11
   43    41        OP_DATA                                                      ~14
   38    42      > JMP                                                          ->13
         43    >   FE_FREE                                                      $10
   46    44        INIT_FCALL                                                   'ksort'
         45        SEND_REF                                                     !1
         46        DO_ICALL                                                     
   47    47        INIT_FCALL                                                   'array_values'
         48        SEND_VAR                                                     !1
         49        DO_ICALL                                             $33     
         50        ASSIGN                                                       !1, $33
   48    51        INIT_FCALL                                                   'print_r'
         52        SEND_VAR                                                     !1
         53        DO_ICALL                                                     
         54      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
159.87 ms | 1944 KiB | 16 Q