Jump to content

if statement with or's involved


fife

Recommended Posts

I have a div I want to show but I want to show it if any of the results from a certain part of my query = 1.  Here is my code

 

 

  <?php if($country['sightseeing']=='1') || if($country['nightlife']=='1') || if($country['hightlights']=='1') || if($country['tips']=='1') || if($country['events']=='1') || 	if($country['news']=='1') || if($country['contrasts']=='1') || if($country['lifestyle']=='1') || if($country['food']=='1') || if($country['food']=='1') { 
//do something 

}  ?>

 

Now I know my sytax here is incorrect but I dont know who you write this any other way.  Can somebody please help me.

 

Thanks

Link to comment
Share on other sites

The if is a construct. You give it a condition, which could be a bunch of conditions ||d together.

if($country['sightseeing']=='1' || $country['nightlife']=='1' || $country['hightlights']=='1' ...)

But it sounds like you simply want to know if there's a 1 anywhere in the $country array?

if(in_array('1', $country))

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.