hyster Posted May 10, 2011 Share Posted May 10, 2011 is there a better way of coding this using arrays? ive never had a use for them b4 the if and the else statment is ok but its the elseif that i think i can put into an array ut what i tryed didnt work. what id like to do $loc = array('HDD', 'APRIL 2011', 'WHITE VISTA', 'NEW 1.5 TB', 'UNVALIDATED') elseif($rows['auth'] == 'YES' and $rows['location'] == $loc){ $bgc = "wait" ; what works if ($rows['auth'] == 'YES' and $rows['location'] == 'SERVER'){ $bgc = "pass" ; } elseif($rows['auth'] == 'YES' and $rows['location'] == 'HDD'){ $bgc = "wait" ; }elseif($rows['auth'] == 'YES' and $rows['location'] == 'APRIL 2011'){ $bgc = "wait" ; }elseif($rows['auth'] == 'YES' and $rows['location'] == 'WHITE VISTA'){ $bgc = "wait" ; }elseif($rows['auth'] == 'YES' and $rows['location'] == 'NEW 1.5 TB'){ $bgc = "wait" ; }elseif($rows['auth'] == 'YES' and $rows['location'] == 'UNVALIDATED'){ $bgc = "wait" ; }else{ $bgc = "fail"; } thx Quote Link to comment https://forums.phpfreaks.com/topic/235991-elseif/ Share on other sites More sharing options...
gizmola Posted May 10, 2011 Share Posted May 10, 2011 Take a look at in_array Quote Link to comment https://forums.phpfreaks.com/topic/235991-elseif/#findComment-1213250 Share on other sites More sharing options...
hyster Posted May 10, 2011 Author Share Posted May 10, 2011 thx gizmola for any1 intrested i solved it with $hddloc = array("HDD","APRIL 2011" ,"WHITE VISTA" ,"NEW 1.5 TB" ,"UNVALIDATED"); if ($rows['auth'] == 'YES' and $rows['location'] == 'SERVER'){ $bgc = "pass" ; } elseif ($rows['auth'] == 'YES' and in_array($rows['location'], $hddloc)) { $bgc = "wait" ; }else{ $bgc = "fail"; } Quote Link to comment https://forums.phpfreaks.com/topic/235991-elseif/#findComment-1213255 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.