如果php中的语句(稍微复杂一些)

Jor*_*iro 1 php if-statement

我有这个问题,我希望有一个动态的if语句,它应该说明:

if (where!= value1 && where!= value2 && ... )
Run Code Online (Sandbox Code Playgroud)

我从数组中获取值,我试图通过破坏它来实现它,类似这样:

if (implode("$where!=" , $columns_array) { ... }
Run Code Online (Sandbox Code Playgroud)

而且我想象这不起作用(我知道为什么它不起作用,这只是我想要做的一个例子)

所以任何人都可以给我一个想法,我该怎么做,或者有办法制作类似的东西

if ($where != (a list of values))
Run Code Online (Sandbox Code Playgroud)

这种语法是否存在?

Kin*_*nch 16

if (!in_array($where, $columns_array)) { /* do something */ }
Run Code Online (Sandbox Code Playgroud)

手册是你的朋友: in_array()