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
https://forums.phpfreaks.com/topic/250432-if-statement-with-ors-involved/
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))

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.