Jordashiro
Jordashiro

Reputation: 805

if statement in php ( a little bit more complex )

I have this issue, I want to have a dynamic if statement and it should state:

if (where!= value1 && where!= value2 && ... )

I am getting the values from an array and I am trying to do it by imploding it, something like this:

if (implode("$where!=" , $columns_array) { ... }

and as I imagined this doesn't work (I know why it doesn't work, that's just an example of what I am trying to do)

So anyone can give me an idea how do I do that, or is there a way to make something like

if ($where != (a list of values))

Does such syntax exist ?

Upvotes: 1

Views: 118

Answers (1)

KingCrunch
KingCrunch

Reputation: 131841

if (!in_array($where, $columns_array)) { /* do something */ }

The manual is your friend: in_array()

Upvotes: 16

Related Questions