3v4l.org

run code in 300+ PHP versions simultaneously
<?php $d = array ( 0 => (object) array( 'b_id' => 1, 'd' => 0, 'lo' => 10, 'm' => 4000, 'pts' => array ( 0 => (object) array( 'amount' => 3500, 'b_id' => 1, 'fid' => 2, 'side' => 2, 'user_id' => 27, ), 1 => (object) array( 'amount' => 3000, 'b_id' => 1, 'fid' => 2, 'side' => 1, 'user_id' => 27, ), 2 => (object) array( 'amount' => 2000, 'b_id' => 1, 'fid' => 2, 'side' => 2, 'user_id' => 20, ), 3 => (object) array( 'amount' => 1000, 'b_id' => 1, 'fid' => 2, 'side' => 1, 'user_id' => 20, ), ), 'ro' => 10, 'side' => 2, 'user_id' => 27, 'w' => 5000, ), 1 => (object) array( 'b_id' => 2, 'd' => 0, 'lo' => 10, 'm' => 6000, 'pts' => array ( 0 => (object) array( 'amount' => 4000, 'b_id' => 2, 'fid' => 2, 'side' => 1, 'user_id' => 27, ), 1 => (object) array( 'amount' => 2000, 'b_id' => 2, 'fid' => 2, 'side' => 2, 'user_id' => 27, ), 2 => (object) array( 'amount' => 1000, 'b_id' => 2, 'fid' => 2, 'side' => 2, 'user_id' => 20, ), 3 => (object) array( 'amount' => 2000, 'b_id' => 2, 'fid' => 2, 'side' => 1, 'user_id' => 20, ), ), 'ro' => 9, 'side' => 1, 'user_id' => 27, 'w' => 3000, ), ); function getOdds($bets, $a, $b) { return $bets * $b / $a; } function getMax($bets, $bet, $max) { $ret = 0; if($bets < $max) { $bets += $bet; $ret = $bets % $max; if($ret == $bets) { $ret = 0; } } else { $ret = $bet; } return $ret; } $break = "\n"; // <br> $break2 = "\n\n"; // <br><br> $collections = []; foreach($d as $row) { $odds = getOdds($row->m, $row->lo, $row->ro); $collection = []; foreach(array_column($row->pts, 'amount') as $amount) { $ret = getMax($row->m, $amount, $odds); // I am assuming that $row-m is supposed to be $bets $amount = round(abs($amount - $ret), 2); $collection[] = implode($break, ["Odds: {$odds}", "Ret: {$ret}", "Amount: {$amount}"]); } $collections[] = implode($break, [ "======[START (b_id: {$row->b_id}]======", implode($break2, $collection), "=======[END (b_id: {$row->b_id}]=======", ]); } echo implode($break2, $collections);

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.5.30.0080.01117.49
8.5.20.0080.01019.49
8.5.10.0130.00616.94
8.5.00.0120.01120.22
8.4.180.0130.00919.68
8.4.170.0120.01123.95
8.4.160.0120.01023.87
8.4.150.0070.00516.81
8.4.140.0110.01017.86
8.4.130.0140.00617.76
8.4.120.0080.00920.62
8.4.110.0110.00919.00
8.4.100.0060.00817.91
8.4.90.0110.00920.61
8.4.80.0120.00318.85
8.4.70.0090.00720.64
8.4.60.0060.00322.13
8.4.50.0110.00822.23
8.4.40.0130.00618.91
8.4.30.0000.00818.80
8.4.20.0040.01517.80
8.4.10.0080.00022.50
8.3.300.0110.00922.76
8.3.290.0130.00818.64
8.3.280.0100.01018.74
8.3.270.0120.00716.87
8.3.260.0130.00816.63
8.3.250.0050.00519.22
8.3.240.0150.00216.66
8.3.230.0080.00616.66
8.3.220.0100.00819.06
8.3.210.0130.00916.99
8.3.200.0090.00916.77
8.3.190.0030.00517.29
8.3.180.0140.00818.91
8.3.170.0100.00917.13
8.3.160.0180.00016.82
8.3.150.0060.00316.87
8.3.140.0070.01118.90
8.3.130.0060.01218.69
8.3.120.0060.00320.80
8.3.110.0080.00016.87
8.3.100.0060.00916.88
8.3.90.0040.00426.77
8.3.80.0030.00716.88
8.3.70.0190.00316.88
8.3.60.0070.00716.88
8.3.50.0140.00623.58
8.3.40.0120.00318.95
8.3.30.0040.01118.95
8.3.20.0070.00024.18
8.3.10.0040.00424.66
8.3.00.0050.00326.16
8.2.300.0140.00718.26
8.2.290.0090.00817.14
8.2.280.0040.00418.98
8.2.270.0090.00918.48
8.2.260.0110.00417.36
8.2.250.0080.00018.60
8.2.240.0090.00916.72
8.2.230.0030.00720.94
8.2.220.0030.00524.06
8.2.210.0080.00026.77
8.2.200.0120.00316.75
8.2.190.0040.01118.29
8.2.180.0070.01425.92
8.2.170.0150.00622.96
8.2.160.0150.00022.96
8.2.150.0080.00025.66
8.2.140.0070.00024.66
8.2.130.0000.00826.16
8.2.120.0040.00426.35
8.2.110.0090.00622.25
8.2.100.0090.00318.02
8.2.90.0030.00718.03
8.2.80.0050.00319.03
8.2.70.0060.00318.16
8.2.60.0040.00418.33
8.2.50.0090.00019.43
8.2.40.0060.00321.01
8.2.30.0000.00719.38
8.2.20.0000.00718.10
8.2.10.0060.00319.29
8.2.00.0040.00419.25
8.1.340.0110.00917.79
8.1.330.0110.00816.48
8.1.320.0090.00316.15
8.1.310.0150.00316.66
8.1.300.0060.01216.99
8.1.290.0060.00330.84
8.1.280.0090.00625.92
8.1.270.0050.00323.99
8.1.260.0050.00328.09
8.1.250.0080.00028.09
8.1.240.0000.00822.31
8.1.230.0080.00321.16
8.1.220.0050.00317.91
8.1.210.0080.00018.77
8.1.200.0140.00317.38
8.1.190.0050.00317.48
8.1.180.0030.00618.97
8.1.170.0030.00518.75
8.1.160.0050.00319.10
8.1.150.0040.00419.01
8.1.140.0040.00418.83
8.1.130.0000.00720.11
8.1.120.0000.00717.43
8.1.110.0000.00717.43
8.1.100.0030.00617.43
8.1.90.0040.00417.49
8.1.80.0030.00517.43
8.1.70.0040.00417.48
8.1.60.0040.00417.63
8.1.50.0030.00617.51
8.1.40.0060.00317.59
8.1.30.0050.00317.66
8.1.20.0040.00417.73
8.1.10.0030.00617.53
8.1.00.0040.00417.63
8.0.300.0040.00420.04
8.0.290.0060.00316.88
8.0.280.0080.00018.43
8.0.270.0030.00517.00
8.0.260.0070.00020.23
8.0.250.0030.00316.95
8.0.240.0070.00016.93
8.0.230.0030.00517.14
8.0.220.0040.00316.86
8.0.210.0030.00316.92
8.0.200.0050.00217.10
8.0.190.0040.00417.10
8.0.180.0040.00417.01
8.0.170.0040.00417.02
8.0.160.0000.00716.98
8.0.150.0030.00316.85
8.0.140.0000.00716.91
8.0.130.0030.00313.49
8.0.120.0000.00817.02
8.0.110.0040.00417.04
8.0.100.0000.00716.97
8.0.90.0030.00617.06
8.0.80.0050.01017.04
8.0.70.0000.00716.91
8.0.60.0050.00216.88
8.0.50.0040.00416.93
8.0.30.0190.00317.09
8.0.20.0170.00317.30
8.0.10.0040.00417.14
8.0.00.0090.00916.68
7.4.330.0000.00515.55
7.4.320.0000.00616.66
7.4.300.0060.00016.59
7.4.290.0000.00716.66
7.4.280.0030.00516.66
7.4.270.0000.00716.54
7.4.260.0050.00013.46
7.4.250.0030.00316.58
7.4.240.0050.00216.59
7.4.230.0070.00016.67
7.4.220.0020.00516.54
7.4.210.0050.01216.63
7.4.200.0030.00316.67
7.4.130.0080.01216.52
7.4.120.0060.01216.66
7.4.110.0070.01016.72
7.4.100.0060.01116.47
7.4.90.0140.00916.75
7.4.80.0110.01119.39
7.4.70.0070.01416.56
7.4.60.0030.01516.61
7.4.50.0140.00716.46
7.4.40.0060.01016.43
7.4.30.0100.00716.68
7.4.20.0100.00716.56
7.4.10.0060.00916.39
7.4.00.0100.00716.46
7.3.330.0000.00716.34
7.3.320.0030.00313.44
7.3.310.0070.00016.39
7.3.300.0000.00716.50
7.3.290.0110.00816.48
7.3.280.0070.00716.44
7.3.260.0120.00616.52
7.3.230.0130.00316.64
7.3.210.0060.01216.55
7.3.200.0130.00316.64
7.3.190.0130.00616.33
7.3.180.0090.00616.64
7.3.170.0050.01116.39
7.3.160.0100.01316.64
7.3.150.0100.00616.59
7.3.140.0070.01016.71
7.3.130.0060.01016.53
7.3.120.0080.00816.57
7.3.110.0180.00016.53
7.3.100.0070.01016.21
7.3.90.0030.01216.23
7.3.80.0030.01416.50
7.3.70.0080.00816.62
7.3.60.0070.01116.49
7.3.50.0140.00316.53
7.3.40.0040.01416.47
7.3.30.0070.01016.45
7.3.20.0860.00316.38
7.3.10.0100.01016.50
7.3.00.0070.01016.58
7.2.330.0060.01816.88
7.2.320.0070.01016.89
7.2.310.0150.00916.80
7.2.300.0130.01016.93
7.2.290.0100.00716.52
7.2.280.0030.01316.39
7.2.270.0140.00316.75
7.2.260.0130.00316.52
7.2.250.0140.00316.82
7.2.240.0120.00616.54
7.2.230.0100.00716.87
7.2.220.0070.01016.50
7.2.210.0070.01016.53
7.2.200.0070.01016.70
7.2.190.0100.00716.67
7.2.180.0090.00616.65
7.2.170.0070.01016.59
7.2.160.0120.00616.66
7.2.150.0100.00716.78
7.2.140.0160.00416.65
7.2.130.0110.01116.72
7.2.120.0100.00716.67
7.2.110.0120.00616.84
7.2.100.0100.00716.80
7.2.90.0070.01116.61
7.2.80.0140.00416.71
7.2.70.0100.00716.75
7.2.60.0030.01416.79
7.2.50.0120.00616.81
7.2.40.0130.00316.83
7.2.30.0060.01216.75
7.2.20.0090.00916.64
7.2.10.0100.00716.58
7.2.00.0130.00416.69

preferences:
54.97 ms | 1588 KiB | 5 Q