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);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [1] => Array ( [round] => Array ( [round] => 1 [positive] => 10 [negative] => 0 [total] => 10 ) ) [2] => Array ( [round] => Array ( [round] => 2 [positive] => 0 [negative] => -50 [total] => -50 ) ) )

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
48.02 ms | 1360 KiB | 4 Q