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 '.(float)$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 $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.60.0100.01018.24
8.3.50.0190.00317.36
8.3.40.0030.01518.92
8.3.30.0090.00618.93
8.3.20.0000.00818.90
8.3.10.0040.00420.60
8.3.00.0080.00017.75
8.2.180.0210.00016.75
8.2.170.0100.01022.96
8.2.160.0070.01022.21
8.2.150.0030.00624.18
8.2.140.0030.00624.66
8.2.130.0050.00326.16
8.2.120.0040.00419.64
8.2.110.0030.00721.18
8.2.100.0060.00617.91
8.2.90.0080.00019.38
8.2.80.0110.00018.05
8.2.70.0060.00317.63
8.2.60.0030.00618.05
8.2.50.0040.00418.07
8.2.40.0000.00819.88
8.2.30.0040.00418.19
8.2.20.0040.00417.90
8.2.10.0080.00017.93
8.2.00.0030.00517.88
8.1.280.0100.00325.92
8.1.270.0030.00623.99
8.1.260.0040.00426.35
8.1.250.0070.00028.09
8.1.240.0100.00020.83
8.1.230.0060.00621.04
8.1.220.0040.00418.77
8.1.210.0040.00418.97
8.1.200.0030.00617.47
8.1.190.0040.00417.63
8.1.180.0000.00918.10
8.1.170.0040.00418.96
8.1.160.0000.00718.91
8.1.150.0040.00418.71
8.1.140.0060.00617.48
8.1.130.0070.00017.46
8.1.120.0040.00417.37
8.1.110.0020.00517.37
8.1.100.0030.00517.50
8.1.90.0030.00517.50
8.1.80.0000.00817.57
8.1.70.0000.00717.52
8.1.60.0030.00517.57
8.1.50.0000.00817.53
8.1.40.0040.00417.64
8.1.30.0040.00417.69
8.1.20.0000.00917.73
8.1.10.0070.00017.64
8.1.00.0040.00717.56
8.0.300.0040.00419.97
8.0.290.0080.00017.00
8.0.280.0040.00418.39
8.0.270.0070.00017.30
8.0.260.0000.00916.94
8.0.250.0050.00217.10
8.0.240.0060.00316.97
8.0.230.0070.00017.03
8.0.220.0000.00716.94
8.0.210.0030.00516.90
8.0.200.0030.00317.07
8.0.190.0000.00717.09
8.0.180.0080.00016.92
8.0.170.0070.00317.02
8.0.160.0030.00316.97
8.0.150.0000.01016.91
8.0.140.0070.00416.86
8.0.130.0050.00213.47
8.0.120.0020.00516.98
8.0.110.0000.00717.05
8.0.100.0020.00516.88
8.0.90.0040.00417.01
8.0.80.0040.01117.05
8.0.70.0000.00717.07
8.0.60.0040.00416.82
8.0.50.0070.00016.91
8.0.30.0140.00717.09
8.0.20.0130.00717.40
8.0.10.0070.00017.19
8.0.00.0120.00716.98
7.4.330.0000.00514.69
7.4.320.0030.00316.55
7.4.300.0000.00616.59
7.4.290.0070.00016.54
7.4.280.0000.01016.43
7.4.270.0000.00816.49
7.4.260.0040.00413.26
7.4.250.0000.00816.62
7.4.240.0080.00016.67
7.4.230.0030.00316.66
7.4.220.0030.01416.60
7.4.210.0080.00916.58
7.4.200.0070.00016.66
7.4.190.0000.00716.74
7.4.160.0080.00816.53
7.4.150.0070.01117.07
7.4.140.0140.00417.14
7.4.130.0110.00716.51
7.4.120.0140.00716.53
7.4.110.0170.00616.73
7.4.100.0120.01216.68
7.4.90.0140.00316.66
7.4.80.0070.01018.80
7.4.70.0110.00716.58
7.4.60.0150.00316.63
7.4.50.0000.00516.52
7.4.40.0040.01121.69
7.4.30.0030.01316.51
7.4.00.0000.01715.07
7.3.330.0030.00313.44
7.3.320.0030.00313.46
7.3.310.0050.00216.30
7.3.300.0050.00316.46
7.3.290.0160.00316.45
7.3.280.0070.01216.46
7.3.270.0060.01217.07
7.3.260.0090.00918.24
7.3.250.0170.00616.41
7.3.240.0070.01016.46
7.3.230.0090.00916.48
7.3.210.0130.00316.39
7.3.200.0090.00819.39
7.3.190.0090.01316.58
7.3.180.0040.01116.37
7.3.170.0160.00716.66
7.3.160.0110.00416.77
7.3.120.0040.01515.14
7.3.110.0070.01415.02
7.3.100.0040.01214.90
7.3.90.0040.01114.70
7.3.80.0040.01114.81
7.3.70.0030.00715.04
7.3.60.0000.01314.92
7.3.50.0040.01414.98
7.3.40.0060.00914.82
7.3.30.0040.00714.61
7.3.20.0070.00716.72
7.3.10.0080.00816.59
7.3.00.0070.01116.53
7.2.330.0180.00316.87
7.2.320.0100.01016.83
7.2.310.0100.01316.96
7.2.300.0060.01116.38
7.2.290.0120.00616.59
7.2.240.0070.01415.28
7.2.230.0070.00715.28
7.2.220.0100.00615.04
7.2.210.0070.00315.05
7.2.200.0000.01115.11
7.2.190.0170.00015.07
7.2.180.0080.00815.10
7.2.170.0070.01015.12
7.2.160.0030.00615.03
7.2.150.0110.00417.07
7.2.140.0000.01117.02
7.2.130.0130.00516.65
7.2.120.0050.01216.85
7.2.110.0070.01016.93
7.2.100.0040.01216.93
7.2.90.0170.00316.80
7.2.80.0080.00916.98
7.2.70.0080.00516.83
7.2.60.0080.00616.81
7.2.50.0100.00716.90
7.2.40.0090.00816.85
7.2.30.0090.00917.01
7.2.20.0070.00816.85
7.2.10.0030.01116.90
7.2.00.0050.00717.71
7.1.330.0060.01315.95
7.1.320.0090.00615.82
7.1.310.0080.00516.00
7.1.300.0060.00915.67
7.1.290.0030.01015.55
7.1.280.0080.00015.68
7.1.270.0060.00615.80
7.1.260.0030.01015.79
7.1.250.0100.01015.77
7.1.200.0030.00515.69
7.1.100.0000.00818.13
7.1.70.0000.01017.18
7.1.60.0120.01219.40
7.1.50.0080.00616.70
7.1.00.0070.06722.36
7.0.200.0030.00316.61
7.0.140.0030.07022.10
7.0.120.0000.03322.04
7.0.60.0170.07319.87
7.0.50.0070.07017.91
7.0.40.0100.07717.69
7.0.30.0170.04717.74
7.0.20.0000.06017.80
7.0.10.0030.04717.70
7.0.00.0070.05017.75
5.6.280.0070.07021.13
5.6.210.0100.08020.73
5.6.200.0100.07718.29
5.6.190.0070.08018.16
5.6.180.0100.08018.29
5.6.170.0070.04318.25
5.6.160.0100.05018.19
5.6.150.0070.05018.29
5.6.140.0170.07018.22
5.6.130.0030.09018.17
5.6.120.0030.06018.19
5.6.110.0000.08718.21
5.6.100.0030.05018.18
5.6.90.0070.08318.14
5.6.80.0030.07017.57
5.6.70.0100.04317.63
5.6.60.0000.04317.53
5.6.50.0000.04717.52
5.6.40.0170.03017.50
5.6.30.0070.06717.55
5.6.20.0070.04317.62
5.6.10.0100.08017.59
5.6.00.0070.07717.48
5.5.350.0330.07020.45
5.5.340.0070.08318.09
5.5.330.0030.05717.95
5.5.320.0100.04318.08
5.5.310.0100.07718.04
5.5.300.0100.04318.04
5.5.290.0030.09318.08
5.5.280.0100.08317.96
5.5.270.0030.05017.96
5.5.260.0030.08017.93
5.5.250.0130.07317.80
5.5.240.0100.04017.44
5.5.230.0030.05017.43
5.5.220.0100.05017.45
5.5.210.0000.04317.34
5.5.200.0070.04317.28
5.5.190.0070.07717.38
5.5.180.0000.05717.43
5.5.160.0070.07017.31
5.5.150.0070.07317.34
5.5.140.0030.05017.34
5.5.130.0100.07017.41
5.5.120.0030.07317.39
5.5.110.0100.07717.33
5.5.100.0070.05317.22
5.5.90.0100.04317.25
5.5.80.0070.07317.30
5.5.70.0100.07317.29
5.5.60.0170.06317.20
5.5.50.0000.05017.25
5.5.40.0030.06017.33
5.5.30.0070.07717.19
5.5.20.0030.06317.20
5.5.10.0070.06717.21
5.5.00.0030.08317.21
5.4.450.0230.06319.50
5.4.440.0030.06319.36
5.4.430.0100.07319.41
5.4.420.0070.08319.42
5.4.410.0130.04319.32
5.4.400.0100.06319.10
5.4.390.0130.06719.02
5.4.380.0030.04719.02
5.4.370.0030.07319.02
5.4.360.0100.07319.07
5.4.350.0070.08019.06
5.4.340.0030.08019.04
5.4.320.0030.05718.99
5.4.310.0030.06018.95
5.4.300.0000.05719.05
5.4.290.0130.06319.27
5.4.280.0100.07719.13
5.4.270.0070.05319.12
5.4.260.0030.08319.04
5.4.250.0070.06319.09
5.4.240.0100.06719.04
5.4.230.0070.07719.03
5.4.220.0130.07018.94
5.4.210.0030.06019.04
5.4.200.0030.08319.12
5.4.190.0070.04319.04
5.4.180.0030.04719.04
5.4.170.0030.04719.13
5.4.160.0070.06019.09
5.4.150.0170.06719.07
5.4.140.0130.05316.59
5.4.130.0130.04016.48
5.4.120.0070.07316.35
5.4.110.0070.04316.64
5.4.100.0070.07016.61
5.4.90.0000.07716.50
5.4.80.0070.07016.51
5.4.70.0170.03016.45
5.4.60.0130.05316.40
5.4.50.0070.04316.40
5.4.40.0170.06016.26
5.4.30.0130.07016.47
5.4.20.0000.07316.57
5.4.10.0130.04316.57
5.4.00.0000.04315.99
5.3.290.0070.07714.66
5.3.280.0070.07714.69
5.3.270.0030.08014.49
5.3.260.0030.07714.67
5.3.250.0070.08014.70
5.3.240.0030.05314.68
5.3.230.0030.08314.73
5.3.220.0130.06714.64
5.3.210.0000.08014.81
5.3.200.0030.07014.71
5.3.190.0030.05314.45
5.3.180.0130.07314.56
5.3.170.0070.03714.67
5.3.160.0170.06014.59
5.3.150.0100.03714.63
5.3.140.0070.07314.55
5.3.130.0130.06314.61
5.3.120.0070.08014.62
5.3.110.0100.07014.66
5.3.100.0030.08014.14
5.3.90.0130.06714.10
5.3.80.0030.04713.93
5.3.70.0100.06014.14
5.3.60.0000.07714.02
5.3.50.0100.06713.88
5.3.40.0030.05714.04
5.3.30.0070.07314.02
5.3.20.0030.04313.75
5.3.10.0070.05713.71
5.3.00.0030.04313.66
5.2.170.0030.04311.17
5.2.160.0130.05311.24
5.2.150.0070.05711.21
5.2.140.0000.04311.23
5.2.130.0070.02711.21
5.2.120.0000.03711.14
5.2.110.0100.02311.21
5.2.100.0030.06711.34
5.2.90.0070.02710.98
5.2.80.0030.05011.18
5.2.70.0000.06711.04
5.2.60.0000.06311.18
5.2.50.0030.03010.95
5.2.40.0000.06711.07
5.2.30.0000.07011.00
5.2.20.0030.04711.21
5.2.10.0000.07010.85
5.2.00.0070.06010.79
5.1.60.0130.04310.10
5.1.50.0100.04710.23
5.1.40.0030.02310.11
5.1.30.0100.05310.36
5.1.20.0130.05010.29
5.1.10.0070.05310.02
5.1.00.0030.06010.10
5.0.50.0000.0438.56
5.0.40.0030.0308.52
5.0.30.0030.0678.26
5.0.20.0030.0278.24
5.0.10.0170.0308.42
5.0.00.0070.0608.41
4.4.90.0000.0207.57
4.4.80.0100.0177.57
4.4.70.0000.0277.57
4.4.60.0070.0207.57
4.4.50.0000.0237.57
4.4.40.0030.0407.57
4.4.30.0070.0337.57
4.4.20.0030.0237.57
4.4.10.0070.0337.57
4.4.00.0070.0437.57
4.3.110.0000.0337.57
4.3.100.0100.0277.57
4.3.90.0070.0277.57
4.3.80.0000.0337.57
4.3.70.0000.0237.57
4.3.60.0070.0177.57
4.3.50.0030.0207.57
4.3.40.0000.0577.57
4.3.30.0000.0337.57
4.3.20.0000.0307.57
4.3.10.0070.0237.57
4.3.00.0000.0177.57

preferences:
74.96 ms | 400 KiB | 5 Q