我正在尝试根据排名为对象定价。我的问题是,如果对象没有排名,它将进入下一层。这是我的代码示例:
switch ($amazonResult['SalesRank']) {
case ($amazonResult['SalesRank'] < 1 || trim($amazonResult['SalesRank'])===''|| !isset($amazonResult['SalesRank']) || $amazonResult['SalesRank']=== null):
$Price=((float) $lowestAmazonPrice) *<some percent to pay>;
$payPrice = round($Price, 0); //to round the price up or down to the nearest $
break;
case ($amazonResult['SalesRank'] > 0 && $amazonResult['SalesRank'] <= 15000):
$Price=((float) $lowestAmazonPrice) * <some percent to pay>;
$payPrice = round($Price, 0); //to round the price up or down to the nearest $
break;
default:
$Price=((float) $lowestAmazonPrice) * <some percent to pay>;
$payPrice = round($Price, 0); //to round the price up or down to the nearest $
break;
}
如果排名为空、null 或 0,如何获取排名?
$amazonResult['SalesRank'] 可以为空,并且是需要在每种情况下进行比较的值。此变量从查询中提取,并在每次要为商品定价时运行