Mr J
Mr J

Reputation: 55

Simple line of code to redo I forget the name

I forgot how to do the following or what it is called.... instead of writing the code like:

if ( $row['level'] != 1 && $row['level'] != 2 && $row['level'] != 3 ) 
{

}

There was a way to make the code above look better. I think it was all put into an array or something. Could you please provide me with the code to make the above look cleaner? Thanks.

Upvotes: 2

Views: 35

Answers (2)

hek2mgl
hek2mgl

Reputation: 157992

Are you searching for in_array()?

if(!in_array($row['level'], array(1,2,3))) {

}

Upvotes: 3

benhowdle89
benhowdle89

Reputation: 37464

if ( $row['level'] > 3 ) 
{

}

Maybe?

Upvotes: 0

Related Questions