newb Posted July 14, 2009 Share Posted July 14, 2009 how do i find out in php if a string contains something in it. like if i wanted to find if apple_333 contained _333 in it. how would i do that in php Quote Link to comment https://forums.phpfreaks.com/topic/165868-php-string-question/ Share on other sites More sharing options...
.josh Posted July 14, 2009 Share Posted July 14, 2009 if it's a simple string within a string (no pattern) you can use strstr or stristr Quote Link to comment https://forums.phpfreaks.com/topic/165868-php-string-question/#findComment-874905 Share on other sites More sharing options...
ldougherty Posted July 14, 2009 Share Posted July 14, 2009 There are several different PHP string functions that you could use to do this. Another would be stripos http://us2.php.net/manual/en/function.stripos.php I suggest familiarizing yourself with the PHP string functions http://us2.php.net/manual/en/book.strings.php Quote Link to comment https://forums.phpfreaks.com/topic/165868-php-string-question/#findComment-874906 Share on other sites More sharing options...
newb Posted July 14, 2009 Author Share Posted July 14, 2009 so which one? Quote Link to comment https://forums.phpfreaks.com/topic/165868-php-string-question/#findComment-874910 Share on other sites More sharing options...
.josh Posted July 14, 2009 Share Posted July 14, 2009 They all look for a string within a string, but with slightly different behaviors. Read the manual entries for them and decide which one best suits your needs. Quote Link to comment https://forums.phpfreaks.com/topic/165868-php-string-question/#findComment-874913 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.