note 76169 added to function.strpbrk
| From: | user at example dot net | Date: | Tue, 03 Jul 2007 19:25:09 +0000 |
| Subject: | note 76169 added to function.strpbrk | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-128188@lists.php.net to get a copy of this message | ||
For PHP versions before 5:
<?php
function strpbrk( $haystack, $char_list )
{
$strlen = strlen($char_list);
$found = false;
for( $i=0; $i<$strlen; $i++ ) {
if( ($tmp = strpos($haystack, $char_list{$i})) !== false ) {
if( !$found ) {
$pos = $tmp;
$found = true;
continue;
}
$pos = min($pos, $tmp);
}
}
if( !$found ) {
return false;
}
return substr($haystack, $pos);
}
?>
Sadly this is about ten times slower than the native implementation.
----
Server IP: 217.13.201.10
Probable Submitter: 87.234.93.227
----
Manual Page -- http://www.php.net/manual/en/function.strpbrk.php
Edit -- https://master.php.net/note/edit/76169
Del: integrated -- https://master.php.net/note/delete/76169/integrated
Del: useless -- https://master.php.net/note/delete/76169/useless
Del: bad code -- https://master.php.net/note/delete/76169/bad+code
Del: spam -- https://master.php.net/note/delete/76169/spam
Del: non-english -- https://master.php.net/note/delete/76169/non-english
Del: in docs -- https://master.php.net/note/delete/76169/in+docs
Del: other reasons-- https://master.php.net/note/delete/76169
Reject -- https://master.php.net/note/reject/76169
Search -- https://master.php.net/manage/user-notes.php