note 24572 deleted from function.substr by aidan
| From: | aidan@php.net | Date: | Sat, 03 Jul 2004 07:53:15 +0000 |
| Subject: | note 24572 deleted from function.substr by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-72383@lists.php.net to get a copy of this message | ||
Note Submitter: php.net@CamelQuotes--NO-SPAM-PLEASE.com
----
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!