note 51578 deleted from function.strripos by betz

From: Date: Tue, 05 Apr 2005 07:39:38 +0000
Subject: note 51578 deleted from function.strripos by betz
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-87476@lists.php.net to get a copy of this message
Note Submitter: rob at dvco Reason: useless ---- Odd behavior when using strripos() from PEAR PHP_Compat on php4.3.2 (OS X): if the needle is not found in the haystack, it does not return false as specified. Rather it returns strlen($needle)*-1 <? include ('PHP_Compat-1.3.1/Compat/Function/strripos.php'); $h = "thequickbrownfox"; echo strripos($h, "quick")."<br>"; echo strripos($h, "blah")."<br>"; echo strripos($h, "foo")."<br>"; ?> OUTPUTS: 3 -4 -3 Luckily, the workaround is pretty easy: $pos = strripos($h, $n); $pos = $pos ? $pos : false;

« previous php.notes (#87476) next »