PHP IF或Else语句 - 最好的方法 [英] PHP IF OR Else statement - best way to do this
本文介绍了PHP IF或Else语句 - 最好的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道执行PHP IF OR语句的最佳方法..但我有一个超过30 +的数组列表
I want to know the best way to do a PHP IF OR statement.. but I have a list of arrays over 30+
这是当前的格式数组:
if($cq=="45" || $cq=="45" || $cq=="35") {
// action to my function
}
我知道我可以做一个数组但是Array();不支持条件..
I know I can do an array but Array(); does not support conditions..
谢谢
更新 - 我知道它已经老了,即使我知道这个和我是新手PHP。看看我的个人资料问题示例(空白的)
UPDATE - I know it is old, even I know that and I am novice PHP. Look at my profile questions example (blank ones)
这是我留下的代码:
if(
$cq=="45" ||
$cq=="53" ||
$cq=="37" ||
$cq=="70" || //
$cq=="74" || //
$cq=="36" || // - this function removes colours if they have this ID
$cq=="66" || //
$cq=="61" || //
$cq=="69" ||
$cq=="20" ||
$cq=="55" ||
$cq=="50")
{
}
推荐答案
$yourArray = ('45', '45', '35'):
if ( in_array($ca, $yourArray) ) { ... }
这篇关于PHP IF或Else语句 - 最好的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文