note 71106 added to function.stripos
| From: | Christopher_Walker at ATT dot net | Date: | Sun, 12 Nov 2006 19:33:54 +0000 |
| Subject: | note 71106 added to function.stripos | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-119637@lists.php.net to get a copy of this message | ||
To be able to use the returned value 0 [zero/FALSE] to indicate that the needle was not found when
the needle is also likely to be found at position 0, prepend a char not likely to be part of the
needle string to the haystack:
<?php
$needle='a';
$haystack='ABC';
$xpos=stripos('*'.$haystack,$needle);
if ($xpos>0) {
$xpos=$xpos-1; //adjust the position with respect to $haystack
echo 'Found at offset ' . $xpos;
}
else
echo 'Not found';
?>
----
Server IP: 216.194.113.175
Probable Submitter: 70.18.209.223
----
Manual Page -- http://www.php.net/manual/en/function.stripos.php
Edit -- https://master.php.net/note/edit/71106
Del: integrated -- https://master.php.net/note/delete/71106/integrated
Del: useless -- https://master.php.net/note/delete/71106/useless
Del: bad code -- https://master.php.net/note/delete/71106/bad+code
Del: spam -- https://master.php.net/note/delete/71106/spam
Del: non-english -- https://master.php.net/note/delete/71106/non-english
Del: in docs -- https://master.php.net/note/delete/71106/in+docs
Del: other reasons-- https://master.php.net/note/delete/71106
Reject -- https://master.php.net/note/reject/71106
Search -- https://master.php.net/manage/user-notes.php