note 9534 added to strpos

From: Date: Thu, 09 Nov 2000 21:24:29 +0000
Subject: note 9534 added to strpos
Groups: php.notes 
Request: Send a blank email to php-notes+get-7546@lists.php.net to get a copy of this message
refering to note of juliano@brasileiros.com.br 10-Sep-2000 11:39 this checks for $pos beeing not a string (it is a number than) and $pos beeing false (meaning 0 or empty). though this would check if $needle was found at the first position of $haystack. this worked fine for me: $pos = strpos($haystack, $needle); if ((string)$pos != "") { //found } $pos = strpos($haystack, $needle); if ((string)$pos == "") { //not found } some of the above mentioned variants didn't work for me. i don't think that -1 is a good way to alter the function because all the old applications wouldn't work anymore. up to me the === is sufficient :-) http://www.php.net/manual/function.strpos.php

« previous php.notes (#7546) next »