phpQuestioner Posted November 10, 2007 Share Posted November 10, 2007 I am trying to check my array with a if else condition, but it does not seem to be working; what do I need to do too make this work - would I explode "asm"? <?php $asm = array("1","2","3","4","5"); if ($cat != "$asm") { echo "Not An Option"; } ?> The above code will echo out "Not An Option" even if $cat is equal to 1, 2, 3, 4, or 5. Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted November 10, 2007 Share Posted November 10, 2007 You need to use the in_array() function. <?php $asm = array("1","2","3","4","5"); if (!in_array($cat, $asm)) { echo "Not An Option"; } ?> Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted November 10, 2007 Author Share Posted November 10, 2007 thanks pocobueno1388 - i was just reading about that in the manual. Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted November 10, 2007 Share Posted November 10, 2007 No problem. Don't forget to press "Topic Solved". Quote Link to comment 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.