note 44900 added to function.strpos
| From: | christian dot NEI_TIL_SPAM at datalogen dot no | Date: | Thu, 19 Aug 2004 18:26:35 +0000 |
| Subject: | note 44900 added to function.strpos | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-74938@lists.php.net to get a copy of this message | ||
If you want to find the position of the first character succeeding $needle, this function does it
for you. $offset is optional.
<?php
function strpos_succ($haystack, $needle) {
$offset = (func_num_args() > 2) ? func_get_arg(2) : 0;
$res = strpos($haystack, $needle, $offset);
return (($res === false) ? false : $res + strlen($needle));
}
?>
Example:
<?php
$str = 'Mighty <a href="nowhere.htm">useful</a> function, this
strpos_succ!';
//Where does the first <a> tag in $str end?
$aPos = strpos_succ($str, ">");
// $aPos=29
?>
----
Manual Page -- http://www.php.net/manual/en/function.strpos.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+44900
Delete -- http://master.php.net/manage/user-notes.php?action=delete+44900&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+44900&report=yes
Search -- http://master.php.net/manage/user-notes.php