PHP:如果a等于b或c或d [英] PHP: If a equals b or c or d
本文介绍了PHP:如果a等于b或c或d的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:
做一些事情的短手:if($ variable == 1 || $ variable ==“ whatever rdquo; || $ variable =='492')。
这是
if ($a==b||$a==c||$a==$d){ ...
描述此逻辑的最短路径。
我在考虑类似
the shortest way to describe this logic. I am thinking about something like
if ($a==($b||$c||$d)) { ...
但这不是有效的代码。有什么建议?
but that is not a valid code. Any suggestions?
推荐答案
你可以使用 in_array :
if( in_array($a, array($b,$c,$d)) ){
//do something
}
这篇关于PHP:如果a等于b或c或d的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文