有沒有更好的方法來重新定義這if()
,我不喜歡這個說法是$prefix
重複一遍又一遍,它看起來很醜。有沒有更好的方法來定義if()條件使用PHP?
if($prefix == 'RSVH' ||
$prefix == 'RSAP' ||
$prefix == 'CMOS' ||
$prefix == 'CMSR' ||
$prefix == 'CMKS' ||
$prefix == 'CMWH' ||
$prefix == 'CMBL' ||
$prefix == 'LNRS' ||
$prefix == 'LNCM' ||
$prefix == 'LNMX' ||
$prefix == 'PMNG');
謝謝你..
你也可以使用開關/箱但下面的建議更好,假設你把前綴放在一個數組中 – Will