note 53518 rejected from function.strripos by betz

From: Date: Sat, 04 Jun 2005 12:29:20 +0000
Subject: note 53518 rejected from function.strripos by betz
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-89917@lists.php.net to get a copy of this message
Note Submitter: keith dot ng at phpdiary dot org ---- At this time of writing, strripos() is only available on PHP5 CVS. If you can't afford to upgrade, the code below will work for you on PHP3/4. It's pretty simple and doesn't use complex loops. ;) function strripos($haystack, $needle) { $haystack = strtolower($haystack); $needle = strtolower($needle); $tmp = strpos(strrev($haystack),strrev($needle)); if ($tmp === false) { return false; } else { return strlen($haystack) - ($tmp + strlen($needle)-1) - 1; } }

« previous php.notes (#89917) next »