Searching if a string exists in another string in PHP

It is possible to use strpos PHP method to investigate if a string exists in another string. This method takes two arguments. First one is a string to search in, second argument is a string to search for.

This method will return either a numeric value, if a substring exists in another string. Please note that the return value is zero based. First element will have a count of zero.

If substring is not found in a string, than this method will return false.

Please be careful when checking value 0. As value 0 can be treated as false.

Comments

Popular posts from this blog

Absolute and relative path in HTML pages

Errors

goto PHP operator