note 14963 added to function.strpos.php
| From: | iaziz at digital4sight dot com | Date: | Wed, 22 Aug 2001 18:03:21 +0000 |
| Subject: | note 14963 added to function.strpos.php | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-16996@lists.php.net to get a copy of this message | ||
Simplest way is:
$pos = strpos ($str, "b");
if (is_string($pos)
//not found
as whenever it finds, it returns some integer, 0,1,2,... which are NOT string, and when it
doesn't, then return '' which is a string! To place a check !$pos doesn't make
sense as
1) if not found: not of ('') is true, is_string is also true
2) if found, is_string is already false as integer <> string, so parser don't touch !$pos
as there is an AND in between.
http://www.php.net/manual/en/function.strpos.php