在php中,我想知道如何检查变量是否等于列表中的任何变量.
我以为我可以尝试类似的东西
if( $example == array($one, $two, $three, $four, $five) ) {
//code here
}
Run Code Online (Sandbox Code Playgroud)
这没用,是否有类似的方法呢?否则,最好的方法是什么?
你的意思是in_array()功能吗?
if( in_array($example, array($one, $two, $three, $four, $five)) ) {
//code here
}
Run Code Online (Sandbox Code Playgroud)