switch (true) { case ($costEgtHundredCount >= 6 && $userCostTotal >= 7500): $grade = 'blue'; # 蓝钻 break; case ($costEgtHundredCount >= 4 && $userCostTotal >= 1500): $grade = 'green'; # 绿钻 break; case ($costEgtHundredCount >= 2): $grade = 'red'; # 红钻 break; default : $grade = 0; }
这里还有个小问题,那就是判断条件从大往小的写,要不会出问题