3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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);
Output for 7.0.0 - 7.1.0
Fatal error: Uncaught Error: Call to undefined function int() in /in/h7ZVV:75 Stack trace: #0 {main} thrown in /in/h7ZVV on line 75
Process exited with code 255.
Output for hhvm-3.12.0 - 3.13.2
Fatal error: Uncaught Error: Call to undefined function int() in /in/h7ZVV:75 Stack trace: #0 {main}
Process exited with code 255.
Output for 5.0.0 - 5.6.25, hhvm-3.10.0
Fatal error: Call to undefined function int() in /in/h7ZVV on line 75
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: int() in /in/h7ZVV on line 75
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: int() in /in/h7ZVV on line 75
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: int() in /in/h7ZVV on line 75