|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[1999-12-15 14:58 UTC] sas at cvs dot php dot net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 10 20:00:02 2026 UTC |
<? $haystack = "123456789"; $needle = "1"; $tmp = strpos($haystack,$needle); if ($tmp) { printf("Yes"); } else { printf("No"); } ?> This prints no, because it returns 0 which is the same as false. The documentation says: If needle is not found, returns false. The problem if needle is at position 0 i haystack then it returns 0 which seems to be the same as false, therefore if needle is at position 0 you get the same result as if it is not in haystack at all. I don't know if this is a bug or just something that should be mentioned in the documentation. Feel free to mail me. Regards Martin.