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. 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!"; } ?> 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
Archived
This topic is now archived and is closed to further replies.