note 95116 added to function.preg-match-all
| From: | adam at bewsher dot com | Date: | Mon, 14 Dec 2009 15:30:27 +0000 |
| Subject: | note 95116 added to function.preg-match-all | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-163933@lists.php.net to get a copy of this message | ||
I've made a slight change to mr davin's findinside function so that it is not limited to
sentences.
<?php
function findinside($start, $end, $string) {
preg_match_all('/'.preg_quote($start,
'/').'([^'.preg_quote($end, '/').']*)'.preg_quote($end,
'/').'/i', $string, $m);
return $m[1];
}
?>
So now,
<?php
$html = "<b>bold {text}</b><a href={howdy.html}>click me</a>";
$ret = findinside("{","}",$html);
print_r($ret);
?>
will return
Array
(
[0] => text
[1] => howdy.html
)
----
Server IP: 69.147.83.197
Probable Submitter: 78.151.121.137
----
Manual Page -- http://www.php.net/manual/en/function.preg-match-all.php
Edit -- https://master.php.net/note/edit/95116
Del: integrated -- https://master.php.net/note/delete/95116/integrated
Del: useless -- https://master.php.net/note/delete/95116/useless
Del: bad code -- https://master.php.net/note/delete/95116/bad+code
Del: spam -- https://master.php.net/note/delete/95116/spam
Del: non-english -- https://master.php.net/note/delete/95116/non-english
Del: in docs -- https://master.php.net/note/delete/95116/in+docs
Del: other reasons-- https://master.php.net/note/delete/95116
Reject -- https://master.php.net/note/reject/95116
Search -- https://master.php.net/manage/user-notes.php