Re: About php String function
| From: | Eugene Lee | Date: | Thu, 25 Sep 2003 05:40:00 +0000 |
| Subject: | Re: About php String function | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-163854@lists.php.net to get a copy of this message | ||
On Thu, Sep 25, 2003 at 10:48:19AM +0530, Uma Shankari T. wrote:
:
: I am using strpos function for finding the string position in a
: particular string .If the string value is equal to zero or greater
: than zero some steps to be executed. If the position is empty it is taking
: as zero value and executing the steps under equal to zero loop..Is there
: any method avoid doing that ??
The online manual for strpos() documents this:
http://www.php.net/manual/en/function.strpos.php
$mystring = 'abc';
$findme = 'a';
$pos = strpos($mystring, $findme);
// Note our use of ===. Simply == would not work as expected
// because the position of 'a' was the 0th (first) character.
if ($pos === false) {
echo "The string '$findme' was not found in the string '$mystring'";
} else {
echo "The string '$findme' was found in the string '$mystring'";
echo " and exists at position $pos";
}