Re: Bug #1323 Updated: strpos and 0th indexed strings
| From: | Mark A. Arnold | Date: | Sun, 18 Apr 1999 14:01:53 +0000 |
| Subject: | Re: Bug #1323 Updated: strpos and 0th indexed strings | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-5116@lists.php.net to get a copy of this message | ||
Please clarify, if you would, what you mean by check it correctly. I cannot use a statement like...
if ( strpos( "abc", "a" ) )
echo "character was found<br>\n";
else
echo "character was not found<br>\n";
...because this code snippet outputs...
character as not found
...which is not the intended result. Further more, the 2 statements...
printf( "pos of \"%s\" in \"%s\" is %d<br>\n", "a",
"abc", strpos( "abc", "a" ) );
printf( "pos of \"%s\" in \"%s\" is %d<br>\n", "z",
"abc", strpos( "abc", "z" ) );
...output...
pos of "a" in "abc" is 0
pos of "z" in "abc" is 0
How do "check it correctly"? How do I tell that the "needle" was not found
versus the "needle" was found
at the beginning of the "haystack"?
Bug Database wrote:
> ID: 1323
> Updated by: rasmus
> Reported By: maarnold@gte.net
> Status: Closed
> Bug Type: Misbehaving function
> Assigned To:
> Comments:
>
> Untrue. false is "" which is different from a string index of 0. You just have to
> check it correctly.
>
> Full Bug description available at: http://bugs.php.net?id=1323
--
PHP Development Mailing List http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net
For help: php-dev-help@lists.php.net