note 76388 added to function.preg-match-all
| From: | mrdavin at osu1 dot php dot net | Date: | Thu, 12 Jul 2007 21:57:51 +0000 |
| Subject: | note 76388 added to function.preg-match-all | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-128423@lists.php.net to get a copy of this message | ||
<?php
// Returns an array of strings where the start and end are found
function findinside($start, $end, $string) {
preg_match_all('/' . preg_quote($start, '/') . '([^\.)]+)'.
preg_quote($end, '/').'/i', $string, $m);
return $m[1];
}
$start = "mary has";
$end = "lambs.";
$string = "mary has 6 lambs. phil has 13 lambs. mary stole phil's lambs. now mary has all
the lambs.";
$out = findinside($start, $end, $string);
print_r ($out);
/* Results in
(
[0] => 6
[1] => all the
)
*/
?>
----
Server IP: 208.69.120.35
Probable Submitter: 209.194.189.187
----
Manual Page -- http://www.php.net/manual/en/function.preg-match-all.php
Edit -- https://master.php.net/note/edit/76388
Del: integrated -- https://master.php.net/note/delete/76388/integrated
Del: useless -- https://master.php.net/note/delete/76388/useless
Del: bad code -- https://master.php.net/note/delete/76388/bad+code
Del: spam -- https://master.php.net/note/delete/76388/spam
Del: non-english -- https://master.php.net/note/delete/76388/non-english
Del: in docs -- https://master.php.net/note/delete/76388/in+docs
Del: other reasons-- https://master.php.net/note/delete/76388
Reject -- https://master.php.net/note/reject/76388
Search -- https://master.php.net/manage/user-notes.php