note 64873 added to function.strpos
| From: | hydesign1 at aol dot com | Date: | Sat, 22 Apr 2006 12:48:56 +0000 |
| Subject: | note 64873 added to function.strpos | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-109010@lists.php.net to get a copy of this message | ||
I've made a workaround of the === boolean operator. Instead of using:
if($pos===false)
I used:
if($pos==true)
It really does the same thing.
Here's my example:
<?php
$inputStr="php rules to the max!";
$searchStr="to";
$searchBool=strpos(" $inputStr",$searchStr);
if($searchBool==true)
{
// found message
echo "The string \"$searchStr\" was found in the string
\"$inputStr\".";
}
else
{
// not found message
echo "The string \"$searchStr\" was not found in the string
\"$inputStr\".";
}
?>
The output would be:
The string "to" was found in the string "php rules to the max!".
----
Server IP: 216.194.113.175
Probable Submitter: 70.105.170.187
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.strpos.php
Edit -- http://master.php.net/note/edit/64873
Del: integrated -- http://master.php.net/note/delete/64873/integrated
Del: useless -- http://master.php.net/note/delete/64873/useless
Del: bad code -- http://master.php.net/note/delete/64873/bad+code
Del: spam -- http://master.php.net/note/delete/64873/spam
Del: non-english -- http://master.php.net/note/delete/64873/non-english
Del: in docs -- http://master.php.net/note/delete/64873/in+docs
Del: other reasons-- http://master.php.net/note/delete/64873
Reject -- http://master.php.net/note/reject/64873
Search -- http://master.php.net/manage/user-notes.php