note 24572 added to function.substr
| From: | php dot net at CamelQuotes--NO-SPAM-PLEASE dot com | Date: | Wed, 21 Aug 2002 21:16:01 +0000 |
| Subject: | note 24572 added to function.substr | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-35320@lists.php.net to get a copy of this message | ||
This returns the string between 2 delimiters:
Example:
$haystack = 'please<a href="/manual/add-note.php">click here</a>';
$start = '<a href="';
$end = '">';
$found = get_string($haystack, $start, $end);
echo $found;
prints:
/manual/add-note.php
NOTE -- NO ERROR CHECKING IS DONE!
--------------
function get_string($h, $s, $e)
{
$sp = strpos($h, $s, 0) + strlen($s);
$ep = strpos($h, $e, 0);
return substr($h, $sp, $ep-$sp);
}
----------------------
Quick and dirty... Very dirty!
--
http://www.php.net/manual/en/function.substr.php
http://master.php.net/manage/user-notes.php?action=edit+24572
http://master.php.net/manage/user-notes.php?action=delete+24572
http://master.php.net/manage/user-notes.php?action=reject+24572