简单的PHP条件帮助:if($ Var1 = in list($ List)and $ Cond2)-这是posslbe吗? [英] Simple PHP Condition help: if($Var1 = in list($List) and $Cond2) - Is this posslbe?
本文介绍了简单的PHP条件帮助:if($ Var1 = in list($ List)and $ Cond2)-这是posslbe吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是可能的功能吗?
我需要检查变量列表中是否存在变量,并且cond2为true 例如
I need to check if a variable is existent in a list of ones I need to check against and also that cond2 is true eg
if($row['name'] == ("1" || "2" || "3") && $Cond2){
doThis();
}
这对我不起作用,我在复制粘贴中所做的更改只是我的列表和变量名
It's not working for me and all I changed in the copy paste was my list and the variable names
推荐答案
if(in_array($row['name'], array('1', '2', '3')) && $Cond2) {
doThis();
}
PHP的in_array()
文档: http://us.php. net/manual/en/function.in-array.php
这篇关于简单的PHP条件帮助:if($ Var1 = in list($ List)and $ Cond2)-这是posslbe吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文