@ 2013-11-12T14:05:07Z <?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);
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
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).
Version System time (s) User time (s) Memory (MiB) 5.4.21 0.013 0.055 12.41 5.4.20 0.016 0.056 12.41 5.4.19 0.015 0.058 12.41 5.4.18 0.012 0.042 12.41 5.4.17 0.010 0.041 12.42 5.4.16 0.015 0.059 12.41 5.4.15 0.016 0.054 12.41 5.4.14 0.016 0.055 12.10 5.4.13 0.011 0.041 12.08 5.4.12 0.025 0.065 12.05 5.4.11 0.015 0.055 12.04 5.4.10 0.013 0.055 12.04 5.4.9 0.017 0.055 12.04 5.4.8 0.014 0.058 12.04 5.4.7 0.015 0.057 12.04 5.4.6 0.018 0.057 12.04 5.4.5 0.017 0.056 12.04 5.4.4 0.011 0.041 12.03 5.4.3 0.017 0.054 12.02 5.4.2 0.014 0.050 12.02 5.4.1 0.010 0.044 12.02 5.4.0 0.009 0.039 11.52 5.3.27 0.010 0.048 12.72 5.3.26 0.010 0.046 12.72 5.3.25 0.018 0.057 12.72 5.3.24 0.020 0.058 12.72 5.3.23 0.015 0.066 12.71 5.3.22 0.024 0.062 12.68 5.3.21 0.015 0.061 12.68 5.3.20 0.018 0.056 12.68 5.3.19 0.013 0.045 12.67 5.3.18 0.016 0.065 12.67 5.3.17 0.011 0.045 12.67 5.3.16 0.011 0.047 12.67 5.3.15 0.014 0.061 12.67 5.3.14 0.016 0.049 12.66 5.3.13 0.018 0.057 12.66 5.3.12 0.013 0.054 12.66 5.3.11 0.013 0.042 12.66 5.3.10 0.014 0.056 12.14 5.3.9 0.013 0.047 12.12 5.3.8 0.016 0.057 12.11 5.3.7 0.015 0.059 12.11 5.3.6 0.016 0.055 12.09 5.3.5 0.007 0.042 12.04 5.3.4 0.014 0.060 12.04 5.3.3 0.013 0.045 12.00 5.3.2 0.017 0.056 11.78 5.3.1 0.016 0.048 11.75 5.3.0 0.015 0.049 11.73
preferences:dark mode live preview
138.64 ms | 1394 KiB | 7 Q