note 91915 deleted from function.strspn by danbrown

From: Date: Wed, 01 Jul 2009 14:31:56 +0000
Subject: note 91915 deleted from function.strspn by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-157779@lists.php.net to get a copy of this message
Note Submitter: XZero ---- 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.

« previous php.notes (#157779) next »