Friday, April 3, 2015

How to search for a specific text within a string - PHP Snippet

How to search for a specific text within a string - PHP Snippet

The PHP strpos() function searches for a specific text within a string.

If a match is found, the function returns the character position of the first match. If no match is found, it will return FALSE.
echo strpos("Hello world!", "world"); // outputs 6

// note: The first character position in a string is 0 (not 1).
Disqus Comments