3v4l.org

run code in 500+ PHP versions simultaneously
<?php $getAllRound = [ [ 'player_name' => 'AC', 'round' => 1, 'winlose' => 10, 'game_title' => 'First', ], [ 'player_name' => 'M3', 'round' => 1, 'winlose' => -50, 'game_title' => 'First', ], [ 'player_name' => 'M2', 'round' => 2, 'winlose' => -50, 'game_title' => 'Second', ], [ 'player_name' => 'M1', 'round' => 2, 'winlose' => -150, 'game_title' => 'Second', ], [ 'player_name' => 'M5', 'round' => 2, 'winlose' => -50, 'game_title' => 'First', ], [ 'player_name' => 'M7', 'round' => 2, 'winlose' => 50, 'game_title' => 'Second', ], ]; $roundsExist = array(); $outputArray = array(); foreach($getAllRound as $playerRound){ if(!in_array($playerRound['round'], $roundsExist)){ $roundsExist[] = $playerRound['round']; $outputArray[$playerRound['round']]['round'] = array( 'round' => $playerRound['round'], 'positive' => 0, 'negative' => 0, 'total' => 0 ); if($playerRound['winlose'] <= 0){ $outputArray[$playerRound['round']]['round']['negative'] += $playerRound['winlose']; }else{ $outputArray[$playerRound['round']]['round']['positive'] += $playerRound['winlose']; } $outputArray[$playerRound['round']]['round']['total'] += $playerRound['winlose']; } } print_r($outputArray);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 44
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 44
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 43
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 31
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 43
Branch analysis from position: 44
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 44
filename:       /in/jeqdQ
function name:  (null)
number of ops:  49
compiled vars:  !0 = $getAllRound, !1 = $roundsExist, !2 = $outputArray, !3 = $playerRound
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                       !0, <array>
   41     1        ASSIGN                                                       !1, <array>
   42     2        ASSIGN                                                       !2, <array>
   43     3      > FE_RESET_R                                           $7      !0, ->44
          4    > > FE_FETCH_R                                                   $7, !3, ->44
   44     5    >   FETCH_DIM_R                                          ~8      !3, 'round'
          6        FRAMELESS_ICALL_2                in_array            ~9      ~8, !1
          7        BOOL_NOT                                             ~10     ~9
          8      > JMPZ                                                         ~10, ->43
   45     9    >   FETCH_DIM_R                                          ~12     !3, 'round'
         10        ASSIGN_DIM                                                   !1
         11        OP_DATA                                                      ~12
   46    12        FETCH_DIM_R                                          ~13     !3, 'round'
   47    13        FETCH_DIM_R                                          ~16     !3, 'round'
         14        INIT_ARRAY                                           ~17     ~16, 'round'
   48    15        ADD_ARRAY_ELEMENT                                    ~17     0, 'positive'
   49    16        ADD_ARRAY_ELEMENT                                    ~17     0, 'negative'
   50    17        ADD_ARRAY_ELEMENT                                    ~17     0, 'total'
   46    18        FETCH_DIM_W                                          $14     !2, ~13
         19        ASSIGN_DIM                                                   $14, 'round'
   50    20        OP_DATA                                                      ~17
   53    21        FETCH_DIM_R                                          ~18     !3, 'winlose'
         22        IS_SMALLER_OR_EQUAL                                          ~18, 0
         23      > JMPZ                                                         ~19, ->31
   54    24    >   FETCH_DIM_R                                          ~20     !3, 'round'
         25        FETCH_DIM_R                                          ~24     !3, 'winlose'
         26        FETCH_DIM_RW                                         $21     !2, ~20
         27        FETCH_DIM_RW                                         $22     $21, 'round'
         28        ASSIGN_DIM_OP                    +=               1          $22, 'negative'
         29        OP_DATA                                                      ~24
   53    30      > JMP                                                          ->37
   56    31    >   FETCH_DIM_R                                          ~25     !3, 'round'
         32        FETCH_DIM_R                                          ~29     !3, 'winlose'
         33        FETCH_DIM_RW                                         $26     !2, ~25
         34        FETCH_DIM_RW                                         $27     $26, 'round'
         35        ASSIGN_DIM_OP                    +=               1          $27, 'positive'
         36        OP_DATA                                                      ~29
   59    37    >   FETCH_DIM_R                                          ~30     !3, 'round'
         38        FETCH_DIM_R                                          ~34     !3, 'winlose'
         39        FETCH_DIM_RW                                         $31     !2, ~30
         40        FETCH_DIM_RW                                         $32     $31, 'round'
         41        ASSIGN_DIM_OP                    +=               1          $32, 'total'
         42        OP_DATA                                                      ~34
   43    43    > > JMP                                                          ->4
         44    >   FE_FREE                                                      $7
   63    45        INIT_FCALL                                                   'print_r'
         46        SEND_VAR                                                     !2
         47        DO_ICALL                                                     
         48      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
166.44 ms | 1994 KiB | 14 Q