N-Bomb(Nerd) Posted November 24, 2008 Share Posted November 24, 2008 Hi, I'm asking my user for input but when I do an "if" statement to see if their input matches something already that's in an array but I can't get it to use the array properly. It will only check against "Word1", what can I do different to make it use the whole array of words? $Wap[0] = "Word1"; $Wap[1] = "Word2"; if (strtolower(Input($Value)) == strtolower($Wap[0]) { echo 'word already exists'; } Link to comment https://forums.phpfreaks.com/topic/133967-solved-compare-string/ Share on other sites More sharing options...
phpSensei Posted November 24, 2008 Share Posted November 24, 2008 Try in_array() I think that is what you want. edit: <?php $words = array('a','b','c'); $check = 'a'; if(in_array($check,$words)){ echo "Sorry but $check is already in the array"; } ?> Link to comment https://forums.phpfreaks.com/topic/133967-solved-compare-string/#findComment-697375 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.