note 473 deleted from function.strpos by jimw
| From: | jimw@php.net | Date: | Thu, 18 Oct 2001 21:23:53 +0000 |
| Subject: | note 473 deleted from function.strpos by jimw | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-19113@lists.php.net to get a copy of this message | ||
The only way I found to test for a string match on the beginning of "haystack" is to use:
if (is_int(strpos($haystack, $needle))) { }
strpos returns an empty string "" if no match is found, an integer otherwise. Therefore
tests like empty(strpos($haystack, $needle))
and
strpos($haystack, $needle) >= 0
don't work, because empty strings "" have a value and are evaluated as 0.