3v4l.org

run code in 300+ PHP versions simultaneously
<?php $players = array ( 0 => array ( 'ID' => '3', 'name' => 'olaf', 'team' => NULL, ), 1 => array ( 'ID' => '4', 'name' => 'Peter', 'team' => NULL, ), 2 => array ( 'ID' => '5', 'name' => 'chris', 'team' => NULL, ), 3 => array ( 'ID' => '6', 'name' => 'günther', 'team' => NULL, ), 4 => array ( 'ID' => '7', 'name' => 'John', 'team' => NULL, ), 5 => array ( 'ID' => '8', 'name' => 'Jack', 'team' => NULL, ), 6 => array ( 'ID' => '9', 'name' => 'Bob', 'team' => NULL, ), 7 => array ( 'ID' => '10', 'name' => 'Jake', 'team' => NULL, ), 8 => array ( 'ID' => '11', 'name' => 'Bill', 'team' => NULL, ) ) ; function constTeams($players){ $numOfPlayers = count($players); $check = array(); $i = 0; while($i < count($players)){ foreach($players as $key => $value){ $random = rand(1,$numOfPlayers); if(!in_array($random, $check) && !array_key_exists($value['name'], $check)){ $check[$value['name']] = $random; $i++; } } } if(count($check) === count($players)){ // no assign team $teamOne = '<br>Team one: '; $teamTwo = '<br>Team two: '; foreach($players as $key => $value){ $gamers[$key] = $value; if($check[$value['name']] % 2 == 0){ $gamers[$key]['team'] = 'Blue'; }else{ $gamers[$key]['team'] = 'Red'; } } } return $gamers; } $output = ' <table> '; foreach(constTeams($players) as $key => $value){ $style = ($value['team'] === 'Red') ? ' style="background-color: #fc7777; color: #610202;"' : ' style="background-color: lightblue; color: darkblue"'; $output .= ' <tr border="1"> <td'.$style.'>'.$value['name'].'</td> </tr>'; } $output .= ' </table>'; echo $output;

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.3.60.0220.01025.92
8.1.130.0040.00817.47
8.1.120.0050.00517.59
8.1.110.0150.00017.41
8.1.100.0090.00617.38
8.1.90.0100.00517.56
8.1.80.0040.00817.61
8.1.70.0000.01017.37
8.1.60.0030.00717.64
8.1.50.0000.01017.52
8.1.40.0060.00317.67
8.1.30.0040.00817.59
8.1.20.0050.00917.74
8.1.10.0160.00317.56
8.1.00.0190.00017.43
8.0.260.0130.00016.95
8.0.250.0110.00316.95
8.0.240.0080.00316.95
8.0.230.0120.00016.95
8.0.220.0080.00316.95
8.0.210.0110.00016.95
8.0.200.0000.01416.95
8.0.190.0040.00716.95
8.0.180.0120.00416.95
8.0.170.0090.00416.95
8.0.160.0030.01016.95
8.0.150.0150.00016.95
8.0.140.0080.00516.95
8.0.130.0110.00316.95
8.0.120.0080.00516.95
8.0.110.0090.00416.95
8.0.100.0120.00216.95
8.0.90.0050.00816.95
8.0.80.0130.00316.95
8.0.70.0040.01317.16
8.0.60.0080.00516.95
8.0.50.0070.00516.95
8.0.30.0060.00616.95
8.0.20.0050.00516.95
8.0.10.0030.00616.95
8.0.00.0030.00716.95
7.4.330.0030.00616.95
7.4.320.0160.00316.95
7.4.300.0070.01316.95
7.4.290.0050.01316.95
7.4.280.0120.00616.95
7.4.270.0170.00316.95
7.4.260.0150.00416.95
7.4.250.0140.00516.95
7.4.240.0180.00216.95
7.4.230.0180.00016.95
7.4.220.0120.00516.95
7.4.210.0110.00716.95
7.4.200.0140.00316.95
7.4.190.0130.00516.95
7.4.180.0140.00416.95
7.4.160.0190.00016.95
7.4.150.0080.00816.95
7.4.140.0170.00016.95
7.4.130.0160.00316.95
7.4.120.0060.01016.95
7.4.110.0140.00316.95
7.4.100.0140.00316.95
7.4.90.0140.00316.95
7.4.80.0140.00316.95
7.4.70.0110.00816.95
7.4.60.0100.00716.77
7.4.50.0140.00316.67
7.4.40.0090.00716.65
7.4.30.0100.00616.60
7.4.20.0090.00916.68
7.4.10.0130.00516.65
7.4.00.0060.01016.73
7.3.330.0070.00716.95
7.3.320.0160.00016.95
7.3.310.0100.00716.95
7.3.300.0210.00016.95
7.3.290.0170.00016.95
7.3.280.0090.00616.95
7.3.270.0110.00516.95
7.3.260.0070.00816.95
7.3.250.0120.00416.95
7.3.240.0100.00616.95
7.3.230.0100.00716.95
7.3.220.0140.00316.95
7.3.210.0170.00016.95
7.3.200.0120.00416.95
7.3.190.0080.00816.95
7.3.180.0070.00916.67
7.3.170.0090.00816.69
7.3.160.0110.00616.67
7.3.150.0050.01116.74
7.3.140.0090.00916.66
7.3.130.0090.00716.74
7.3.120.0100.00516.71
7.3.110.0020.01416.66
7.3.100.0120.00516.82
7.3.90.0100.00816.64
7.3.80.0110.00716.74
7.3.70.0100.00616.77
7.3.60.0100.00616.69
7.3.50.0100.00716.66
7.3.40.0130.00616.68
7.3.30.0100.00716.69
7.3.20.0080.00916.63
7.3.10.0150.00616.75
7.3.00.0120.00516.76
7.2.340.0160.00016.95
7.2.330.0170.00016.95
7.2.320.0170.00016.95
7.2.310.0110.00516.88
7.2.300.0090.00816.87
7.2.290.0060.01016.86
7.2.280.0060.01016.86
7.2.270.0040.01516.93
7.2.260.0150.00216.85
7.2.250.0100.00716.87
7.2.240.0090.00716.88
7.2.230.0100.00816.77
7.2.220.0130.00416.67
7.2.210.0070.01016.92
7.2.200.0090.00816.80
7.2.190.0070.01016.90
7.2.180.0090.00816.86
7.2.170.0110.00616.81
7.2.160.0120.00416.86
7.2.150.0110.00816.88
7.2.140.0130.00716.81
7.2.130.0070.00916.89
7.2.120.0110.00516.80
7.2.110.0100.00716.90
7.2.100.0140.00316.88
7.2.90.0110.00716.76
7.2.80.0080.00916.83
7.2.70.0130.00316.86
7.2.60.0080.00916.80
7.2.50.0160.00616.84
7.2.40.0080.01016.84
7.2.30.0150.00316.96
7.2.20.0120.00816.79
7.2.10.0120.00716.82
7.2.00.0090.00916.83

preferences:
34.39 ms | 403 KiB | 5 Q