ランキングに基づいてオブジェクトの価格を設定しようとしています。私の問題は、オブジェクトにランキングがない場合、次の層に移動することです。これが私のコードのサンプルです:
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'] は空である可能性があり、その都度比較する必要がある値です。この変数はクエリから取得され、アイテムの価格が設定されるたびに実行されます