3v4l.org

run code in 300+ PHP versions simultaneously
<?php function Price($c,$pid){ //return '0.00'; $p=array(); $mintcard=array(); if(count($c)===0) return false; foreach($c as $comp => $competitor){ $p[] = $competitor['price']; if($comp=='mtgmintcard'){ $mintcard['stock'] = (int)$competitor['stock']; $mintcard['price'] = (float)$competitor['price']; } } if(count($mintcard)===0) return false; $min = _MIN($p); $avg = _AVG($p); if($mintcard['stock']===-1){ $foil=1; $pid = 40230; if($pid!==false){ $mintcard['stock'] = 24; }else{ $mintcard['stock'] = 0; } }else{ $foil=0; } if($mintcard['stock']>=1){ switch(true){ case $min <= 0.10: $price = (30 > 35 ? 0.05 : $min); break; case $min > 0.10 && $min < 0.16: $price = bcmul($min,1,2); break; case $min >= 0.16 && $min <= 0.99: $price = bcmul($avg,0.95,2); break; case $min >= 1.00 && $min <= 1.99: $price = bcdiv(bcmul((bcadd($avg,$mintcard['price'],2)),0.95,2),2,2) ; break; // + mtg price case $min >= 2.00: $price = bcmul($min,0.99,2); break; default: $price = 0; break; } }elseif($mintcard['stock']===0){ //switch(true){ /*case $min <= 0.10: $price = (_SQL_FETCHSTOCK($pid) > 35 ? 0.05 : $min); break; case $min >= 0.10 && $min < 0.16: $price = bcmul($min,0.99,2); break; case $min >= 0.16 && $min <= 0.99: $price = bcmul($avg,0.95,2); break; case $min >= 1.00 : $price = bcdiv(bcmul((bcadd($avg,$mintcard['price'],2)),0.95,2),2,2); break; // + mtg price default: $price = false; break;*/ //} $price = $avg; } if($foil===1){ $foilPrice = FoilPrice($price); echo ('pricing '.$pid.' Foil identified: increased price from '.(float)$price.' to '.$foilPrice); $price = $foilPrice; } return (float)$price; } function FoilPrice($price){ switch(true){ case $price <= 1.00: $fprice = bcmul($price,3,2); break; case $price > 1.00 && $price <= 10.00: $fprice = bcmul($price,2.5,2); break; case $price > 10.00: $fprice = bcmul($price,2,2); break; } return (float)$fprice; } function _AVG($args){ /*$count = func_num_args(); $args = func_get_args();*/ $count = count($args); $sum = array_sum($args); return bcdiv($sum,$count,2); } function _MIN($args){ return min($args); } $arr = array( "mtgmintcard"=> array( "date_id"=>(int)67, "price"=>(float)0.2, "stock"=>(int)-1 ), "manaleak"=> array( "date_id"=>(int)67, "price"=>(float)0.35, "stock"=>(int)-1 ), "magicmadhouse"=> array( "date_id"=>(int)67, "price"=>(float)0.49, "stock"=>(int)-1 ), ); echo Price($arr,57521);

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.40.0060.00918.88
8.3.30.0100.00320.33
8.3.20.0040.00418.94
8.3.10.0050.00321.06
8.3.00.0040.00423.52
8.2.170.0140.00322.96
8.2.160.0030.01020.52
8.2.150.0060.00324.18
8.2.140.0040.00424.66
8.2.130.0080.00026.16
8.2.120.0000.00819.83
8.2.110.0130.00321.96
8.2.100.0030.00917.91
8.2.90.0040.00419.16
8.2.80.0000.00919.21
8.2.70.0060.00317.63
8.2.60.0050.00317.93
8.2.50.0050.00318.07
8.2.40.0030.00518.34
8.2.30.0000.00819.40
8.2.20.0050.00317.90
8.2.10.0000.00817.92
8.2.00.0100.00017.88
8.1.270.0080.00023.99
8.1.260.0080.00026.35
8.1.250.0030.00628.09
8.1.240.0060.00322.47
8.1.230.0080.00421.04
8.1.220.0080.00018.77
8.1.210.0000.00818.93
8.1.200.0060.00317.50
8.1.190.0090.00017.79
8.1.180.0000.00818.10
8.1.170.0060.00318.71
8.1.160.0040.00418.92
8.1.150.0050.00318.72
8.1.140.0040.00417.57
8.1.130.0040.00417.88
8.1.120.0000.00717.52
8.1.110.0080.00017.49
8.1.100.0000.00717.50
8.1.90.0000.00817.50
8.1.80.0070.00017.55
8.1.70.0030.00317.47
8.1.60.0040.00417.64
8.1.50.0020.00517.52
8.1.40.0030.00617.48
8.1.30.0040.00417.66
8.1.20.0000.00817.61
8.1.10.0000.00817.68
8.1.00.0060.00317.57
8.0.300.0000.00920.24
8.0.290.0080.00017.16
8.0.280.0030.00318.54
8.0.270.0030.00317.37
8.0.260.0000.00616.88
8.0.250.0040.00417.01
8.0.240.0070.00417.14
8.0.230.0030.00317.02
8.0.220.0030.00317.05
8.0.210.0040.00416.88
8.0.200.0080.00016.94
8.0.190.0040.00417.13
8.0.180.0000.00717.05
8.0.170.0040.00416.96
8.0.160.0080.00016.99
8.0.150.0000.00716.86
8.0.140.0060.00617.04
8.0.130.0060.00013.38
8.0.120.0100.00016.99
8.0.110.0000.00816.89
8.0.100.0000.00717.05
8.0.90.0000.00717.08
8.0.80.0070.01016.90
8.0.70.0040.00416.81
8.0.60.0040.00416.85
8.0.50.0020.00517.07
8.0.30.0100.01017.23
8.0.20.0160.00517.42
8.0.10.0000.00717.03
8.0.00.0120.00816.87
7.4.330.0000.00516.77
7.4.320.0030.00316.46
7.4.300.0000.00716.46
7.4.290.0070.00016.46
7.4.280.0000.00816.68
7.4.270.0000.00716.64
7.4.260.0050.00013.33
7.4.250.0040.00416.61
7.4.240.0070.00016.50
7.4.230.0000.00716.75
7.4.220.0200.00616.50
7.4.210.0120.00316.63
7.4.200.0070.00016.66
7.4.190.0040.00416.52
7.4.160.0100.00616.32
7.4.150.0130.00317.40
7.4.140.0130.00517.86
7.4.130.0110.00616.50
7.4.120.0100.00816.53
7.4.110.0160.00616.36
7.4.100.0160.00016.51
7.4.90.0140.00416.56
7.4.80.0030.01419.39
7.4.70.0090.00816.48
7.4.60.0040.01616.55
7.4.50.0090.00016.36
7.4.40.0030.01022.77
7.4.30.0150.00416.34
7.4.00.0070.01015.03
7.3.330.0030.00313.38
7.3.320.0030.00313.23
7.3.310.0030.00316.29
7.3.300.0000.00816.44
7.3.290.0030.01116.48
7.3.280.0130.00516.46
7.3.270.0090.00917.40
7.3.260.0160.00618.24
7.3.250.0100.00916.39
7.3.240.0130.00316.60
7.3.230.0170.00016.64
7.3.210.0070.01016.57
7.3.200.0140.00719.39
7.3.190.0060.01216.47
7.3.180.0100.00716.68
7.3.170.0150.00316.40
7.3.160.0090.00616.49
7.3.120.0060.00914.99
7.3.10.0060.00616.63
7.3.00.0060.00916.47
7.2.330.0100.00716.86
7.2.320.0150.00716.76
7.2.310.0130.01016.51
7.2.300.0160.00016.90
7.2.290.0100.00716.85
7.2.130.0130.00616.52
7.2.120.0090.00616.77
7.2.110.0150.00616.73
7.2.100.0120.00316.31
7.2.90.0030.01016.90
7.2.80.0120.00316.66
7.2.70.0130.00316.56
7.2.60.0030.01016.79
7.2.50.0090.00316.94
7.2.40.0140.01016.55
7.2.30.0090.00916.48
7.2.20.0110.01116.99
7.2.10.0110.00516.68
7.2.00.0080.01318.23
7.1.250.0090.00615.37
7.1.100.0030.01217.82
7.1.70.0000.00817.07
7.1.60.0200.00719.17
7.1.50.0040.01917.02
7.1.00.0100.03722.36
7.0.200.0060.00916.78
7.0.140.0070.07022.18
7.0.100.0100.07319.95
7.0.90.0130.07020.00
7.0.80.0100.07720.08
7.0.70.0000.06319.91
7.0.60.0230.07320.08
7.0.50.0130.07020.38
7.0.40.0070.08320.19
7.0.30.0130.07720.12
7.0.20.0100.08020.05
7.0.10.0100.08320.10
7.0.00.0100.04320.14
5.6.280.0000.07721.10
5.6.250.0130.08320.64
5.6.240.0170.04720.51
5.6.230.0130.07320.61
5.6.220.0030.04720.63
5.6.210.0100.09320.73
5.6.200.0070.08721.06
5.6.190.0100.08020.95
5.6.180.0070.07721.07
5.6.170.0130.07720.98
5.6.160.0070.07321.19
5.6.150.0100.07721.08
5.6.140.0200.08021.18
5.6.130.0030.09021.07
5.6.120.0100.07721.05
5.6.110.0170.06321.05
5.6.100.0070.08721.07
5.6.90.0030.05021.12
5.6.80.0030.08020.42
5.6.70.0100.07720.50
5.6.60.0100.07720.33
5.6.50.0070.06320.51
5.6.40.0030.07720.32
5.6.30.0070.07720.47
5.6.20.0130.07320.41
5.6.10.0000.05020.41
5.6.00.0070.08020.32
5.5.380.0130.07720.38
5.5.370.0130.06720.39
5.5.360.0170.07320.43
5.5.350.0030.08720.47
5.5.340.0100.07020.75
5.5.330.0070.06320.83
5.5.320.0070.06720.76
5.5.310.0030.08320.80
5.5.300.0070.08720.94
5.5.290.0070.08020.82
5.5.280.0030.07320.88
5.5.270.0170.07020.88
5.5.260.0130.07720.94
5.5.250.0130.07020.75
5.5.240.0130.07320.29
5.5.230.0100.08020.13
5.5.220.0070.07320.29
5.5.210.0000.07720.16
5.5.200.0100.07720.15
5.5.190.0100.08320.28
5.5.180.0070.08020.02
5.5.160.0100.07020.20
5.5.150.0030.06320.26
5.5.140.0000.08020.13
5.5.130.0070.08320.11
5.5.120.0070.05720.02
5.5.110.0170.03720.14
5.5.100.0100.07020.10
5.5.90.0100.06020.15
5.5.80.0030.04720.09
5.5.70.0130.07720.18
5.5.60.0130.05020.02
5.5.50.0070.06020.08
5.5.40.0030.04019.96
5.5.30.0130.07320.08
5.5.20.0030.08319.95
5.5.10.0070.05020.07
5.5.00.0070.07720.03
5.4.450.0130.07319.18
5.4.440.0070.07719.42
5.4.430.0000.06719.27
5.4.420.0100.04319.46
5.4.410.0070.07719.23
5.4.400.0130.07319.05
5.4.390.0030.08019.05
5.4.380.0030.07719.12
5.4.370.0030.08018.91
5.4.360.0070.08019.14
5.4.350.0030.07719.16
5.4.340.0030.07319.03
5.4.320.0130.06019.03
5.4.310.0100.08319.14
5.4.300.0070.06718.94
5.4.290.0070.07719.09
5.4.280.0170.07018.96
5.4.270.0100.07018.95
5.4.260.0200.06318.84
5.4.250.0200.06318.89
5.4.240.0070.07719.24
5.4.230.0070.06318.87
5.4.220.0000.04318.94
5.4.210.0030.04718.90
5.4.200.0070.03719.08
5.4.190.0030.09719.04
5.4.180.0170.06719.02
5.4.170.0000.08718.93
5.4.160.0030.08018.85
5.4.150.0170.06719.14
5.4.140.0030.07016.53
5.4.130.0100.05716.37
5.4.120.0130.07016.46
5.4.110.0070.07316.55
5.4.100.0170.06316.45
5.4.90.0100.06716.58
5.4.80.0030.04016.50
5.4.70.0100.06716.54
5.4.60.0070.04316.48
5.4.50.0030.04716.31
5.4.40.0130.06016.45
5.4.30.0100.06316.36
5.4.20.0170.06316.47
5.4.10.0100.07016.48
5.4.00.0030.05315.82
5.3.290.0100.05314.81
5.3.280.0000.07714.69
5.3.270.0000.04714.66
5.3.260.0130.07314.77
5.3.250.0130.07014.60
5.3.240.0070.06714.61
5.3.230.0030.04714.62
5.3.220.0100.04014.69
5.3.210.0070.04014.63
5.3.200.0030.06714.57
5.3.190.0070.08014.72
5.3.180.0030.07314.75
5.3.170.0000.04714.52
5.3.160.0070.08014.70
5.3.150.0070.05014.71
5.3.140.0070.08014.68
5.3.130.0100.04014.52
5.3.120.0070.07714.64
5.3.110.0070.06314.51
5.3.100.0100.07314.13
5.3.90.0100.07314.11
5.3.80.0100.07014.11
5.3.70.0070.07313.97
5.3.60.0130.07014.14
5.3.50.0170.06314.05
5.3.40.0100.06714.09
5.3.30.0030.08014.05
5.3.20.0070.07713.87
5.3.10.0030.04013.75
5.3.00.0070.06713.70
5.2.170.0070.06012.20
5.2.160.0000.05012.20
5.2.150.0130.04712.20
5.2.140.0070.05712.20
5.2.130.0100.04712.20
5.2.120.0100.05012.20
5.2.110.0000.06712.20
5.2.100.0030.03012.20
5.2.90.0070.06012.20
5.2.80.0070.06012.20
5.2.70.0130.04712.20
5.2.60.0070.06012.20
5.2.50.0100.03312.20
5.2.40.0030.03312.20
5.2.30.0070.05312.20
5.2.20.0130.05012.20
5.2.10.0030.04712.20
5.2.00.0000.05312.20
5.1.60.0030.03312.20
5.1.50.0030.04712.20
5.1.40.0030.05312.20
5.1.30.0030.06012.20
5.1.20.0070.05312.20
5.1.10.0030.04712.20
5.1.00.0100.05012.20
5.0.50.0070.02312.20
5.0.40.0100.04012.20
5.0.30.0070.06312.20
5.0.20.0030.04712.20
5.0.10.0030.03712.20
5.0.00.0030.03312.20
4.4.90.0030.03312.20
4.4.80.0000.03312.20
4.4.70.0000.02312.20
4.4.60.0000.03012.20
4.4.50.0030.02312.20
4.4.40.0030.05312.20
4.4.30.0000.03312.20
4.4.20.0000.03312.20
4.4.10.0030.04012.20
4.4.00.0030.05012.20
4.3.110.0070.01712.20
4.3.100.0030.03312.20
4.3.90.0030.02312.20
4.3.80.0070.03312.20
4.3.70.0000.03012.20
4.3.60.0100.02012.20
4.3.50.0000.03712.20
4.3.40.0100.03712.20
4.3.30.0070.02712.20
4.3.20.0000.03012.20
4.3.10.0000.03312.20
4.3.00.0070.02712.20

preferences:
39.08 ms | 400 KiB | 5 Q