fife Posted November 4, 2011 Share Posted November 4, 2011 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 More sharing options...
requinix Posted November 4, 2011 Share Posted November 4, 2011 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 https://forums.phpfreaks.com/topic/250432-if-statement-with-ors-involved/#findComment-1284890 Share on other sites More sharing options...
fife Posted November 4, 2011 Author Share Posted November 4, 2011 yes thankyou the second solution there is perfect. Link to comment https://forums.phpfreaks.com/topic/250432-if-statement-with-ors-involved/#findComment-1284892 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.