c_pattle Posted October 12, 2010 Share Posted October 12, 2010 I was wondering if it is possible to check the content for a variable for a certain work. For example say a variable called "$variable1" was equal to "one, two, three, four, five". How can I check to see if the variable contain the word "four"? Thanks for any help. Quote Link to comment Share on other sites More sharing options...
litebearer Posted October 12, 2010 Share Posted October 12, 2010 Might check... http://www.w3schools.com/php/func_string_stripos.asp Quote Link to comment Share on other sites More sharing options...
Oziam Posted October 12, 2010 Share Posted October 12, 2010 $string = 'four'; $variable1 = array("one","two","three","four","five"); echo in_array($string, $variable1) ? 'TRUE' : 'FALSE'; or if(in_array($string, $variable1)){ echo 'TRUE'; // do something } else{ echo 'FALSE'; // do something else } 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.