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((float)$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 (float)bcdiv($sum,$count,2); } function _MIN($args){ return (float)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)
5.4.210.0130.05512.41
5.4.200.0160.05612.41
5.4.190.0150.05812.41
5.4.180.0120.04212.41
5.4.170.0100.04112.42
5.4.160.0150.05912.41
5.4.150.0160.05412.41
5.4.140.0160.05512.10
5.4.130.0110.04112.08
5.4.120.0250.06512.05
5.4.110.0150.05512.04
5.4.100.0130.05512.04
5.4.90.0170.05512.04
5.4.80.0140.05812.04
5.4.70.0150.05712.04
5.4.60.0180.05712.04
5.4.50.0170.05612.04
5.4.40.0110.04112.03
5.4.30.0170.05412.02
5.4.20.0140.05012.02
5.4.10.0100.04412.02
5.4.00.0090.03911.52
5.3.270.0100.04812.72
5.3.260.0100.04612.72
5.3.250.0180.05712.72
5.3.240.0200.05812.72
5.3.230.0150.06612.71
5.3.220.0240.06212.68
5.3.210.0150.06112.68
5.3.200.0180.05612.68
5.3.190.0130.04512.67
5.3.180.0160.06512.67
5.3.170.0110.04512.67
5.3.160.0110.04712.67
5.3.150.0140.06112.67
5.3.140.0160.04912.66
5.3.130.0180.05712.66
5.3.120.0130.05412.66
5.3.110.0130.04212.66
5.3.100.0140.05612.14
5.3.90.0130.04712.12
5.3.80.0160.05712.11
5.3.70.0150.05912.11
5.3.60.0160.05512.09
5.3.50.0070.04212.04
5.3.40.0140.06012.04
5.3.30.0130.04512.00
5.3.20.0170.05611.78
5.3.10.0160.04811.75
5.3.00.0150.04911.73

preferences:
138.64 ms | 1394 KiB | 7 Q