note 91915 added to function.strspn
| From: | XZero at osu1 dot php dot net | Date: | Wed, 01 Jul 2009 14:23:41 +0000 |
| Subject: | note 91915 added to function.strspn | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-157776@lists.php.net to get a copy of this message | ||
Re:Dmitry Mazur
[quote]strspn will return an zero-based index of a first non-allowed character.[/quote]
That's incorrect. As noted above in the documentation and below in barry's note, strspn
returns the length of the longest substring in $str1 consisting exclusively of characters from
$str2.
If strspn returned the index of the first non-allowed character, then Example #1 in the
documentation should not return 2, since it starts searching from the first _allowed_ character. Had
the $start and $length parameters been omitted, the code would still return 2 (not 0, as it would be
if you were correct), since the length of the longest substring of "foo" containing only
the letter "o" is 2.
----
Server IP: 208.69.120.35
Probable Submitter: 8.15.142.207
----
Manual Page -- http://www.php.net/manual/en/function.strspn.php
Edit -- https://master.php.net/note/edit/91915
Del: integrated -- https://master.php.net/note/delete/91915/integrated
Del: useless -- https://master.php.net/note/delete/91915/useless
Del: bad code -- https://master.php.net/note/delete/91915/bad+code
Del: spam -- https://master.php.net/note/delete/91915/spam
Del: non-english -- https://master.php.net/note/delete/91915/non-english
Del: in docs -- https://master.php.net/note/delete/91915/in+docs
Del: other reasons-- https://master.php.net/note/delete/91915
Reject -- https://master.php.net/note/reject/91915
Search -- https://master.php.net/manage/user-notes.php