3v4l.org

run code in 300+ PHP versions simultaneously
<?php <style> .n {background-color:#AAF} .p {background-color:#FAA} table {font-family:Courier; font-size:12px;} .gray {color:#AAA;} </style> <table> <?php $plays = 100; $ticket_price = 2; $wins_titles = array('No match', '0 + PB','1','1 + PB','2','2 + PB','3','3 + PB','4','4 + PB','5','Jackpot!'); $wins_payouts = array(0,4,0,4,0,7,7,100,100,50000,1000000,1500000000); $draw = array(); for($d=0; $d<5; $d++){ $n = rand(1,69); while(in_array($n, $draw)){ $n = rand(1,69); } $draw[] = $n; } $draw_pb = rand(1,26); $rules = array("Any numbers 1 - 69"=>false, "Only 32 and higher"=>32, "Only 65-69"=>65); echo '<table cellpadding=20><tr><td colspan="2">'; echo '<b>Numbers drawn:</b> <span class="n">'.implode('</span> <span class="n">', $draw).'</span> <span class="p">'.$draw_pb.'</span>'; echo '</td></tr><tr>'; foreach($rules AS $rule => $lowest_number) { echo '<td>'; echo "<b>{$rule}</b></br>"; $total_wins_value = 0; $wins = array(0,0,0,0,0,0,0,0,0,0,0,0); $min = $lowest_number ? $lowest_number : 1; //$min = false; for ($i=0; $i<$plays; $i++) { $play = array(); for($d=0; $d<5; $d++){ $n = rand($min,69); while(in_array($n, $play)){ $n = rand($min,69); } $play[] = $n; } $play_pb = rand(1, 26); $play_matches = 0; foreach($play AS $num){ if (in_array($num, $draw)) { $play_matches++; echo ' <span class="n">'.($num<10?'&nbsp;':'').$num.'</span>'; } else{ echo ' '.($num<10?'&nbsp;':'').$num; } } $pb_match = $play_pb==$draw_pb; if ($pb_match) { echo ' [<span class="p">'.($play_pb<10?'&nbsp;':'').$play_pb.'</span>] '; } else { echo ' ['.($play_pb<10?'&nbsp;':'').$play_pb.'] '; } $score = $play_matches*2 + ($pb_match?1:0); $wins[$score]++; echo "Score: {$score}<br/>"; } $total_wins_value = 0; ?><hr> <table> <tr><th>Match</th><th>Payout</th><th>Count</th><th>Total Win</th></tr> <?php foreach($wins AS $index=>$count): ?> <tr <?= ($index==0 || $index==2 || $index==4 ? 'class="gray"':'') ?>> <td><?= $wins_titles[$index] ?></td> <td>$<?= number_format($wins_payouts[$index],0) ?></td> <td><?= $count ?></td> <?php $win_value = $wins_payouts[$index]*$count; $total_wins_value += $win_value; ?> <td>$<?= number_format($win_value,0) ?></td> </tr> <?php endforeach; ?> </table> <hr> Tickets: <b><?= number_format($plays,0) ?></b><br/> Spent: <b>$<?= number_format(($spent=$plays*$ticket_price),0) ?></b><br/> Won: <b>$<?= number_format($total_wins_value,0) ?></b><br/> Profit: <b><?= number_format(($total_wins_value-$spent)/$spent*100,2) ?>%</b> <hr/><hr/> <?php echo '</td>'; } echo '</tr></table>';

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)
7.0.20.0330.04720.16
7.0.10.0100.08020.22
7.0.00.0070.08020.09
5.6.170.0270.05320.47
5.6.160.0070.05720.44
5.6.150.0070.04318.19
5.6.140.0130.04318.11
5.6.130.0100.05318.24
5.6.120.0030.06320.98
5.6.110.0030.08721.04
5.6.100.0070.08321.02
5.6.90.0030.09320.97
5.6.80.0070.06720.37
5.5.310.0170.04320.23
5.5.300.0000.04017.91
5.5.290.0070.04318.07
5.5.280.0070.04020.76
5.5.270.0030.04320.61
5.5.260.0070.05020.75
5.5.250.0200.07020.69
5.5.240.3170.03720.18

preferences:
137.36 ms | 1394 KiB | 7 Q