johnsmith153 Posted January 3, 2009 Share Posted January 3, 2009 I am not a child, but my question is simple: How would I check if a certain value existed in a string? ie. check if the letter "e" exists is the string "Hello" I normally use: $b="Hello"; $a=str_replace("e", "", $b); if($a!=$b){echo "The letter DOES exist";} But this is a silly method. Quote Link to comment https://forums.phpfreaks.com/topic/139334-so-simple-even-a-child-could-do-it/ Share on other sites More sharing options...
premiso Posted January 3, 2009 Share Posted January 3, 2009 strstr or stristr Would be the way. <?php $string = "hello"; if (stristr($string, "e") !== false) { echo $string . " has e in it!"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/139334-so-simple-even-a-child-could-do-it/#findComment-728780 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.