note 79930 deleted from function.substr by felipe
| From: | felipe@php.net | Date: | Mon, 24 Dec 2007 01:11:53 +0000 |
| Subject: | note 79930 deleted from function.substr by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-133912@lists.php.net to get a copy of this message | ||
Note Submitter: anon
Reason: 1
----
I made a function that extract data between characters.
<?php
$str = "<b>Bold Text 1</b><b>Bold Text 2</b>";
$boldedText = between("<b>", "</b>", $str);
print_r($boldedText);
function between($start, $end, $source) {
while ($s != strlen($start)) {
$s = strpos($source, $start, $s) + strlen($start);
if ($s == strlen($start)) continue;
$r[] = substr($source, $s, strpos($source, $end, $s) - $s);
}
return (count($r) <= 1 ? $r[0] : $r);
}
?>