note 95116 deleted from function.preg-match-all by danbrown

From: Date: Mon, 14 Dec 2009 15:58:47 +0000
Subject: note 95116 deleted from function.preg-match-all by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-163934@lists.php.net to get a copy of this message
Note Submitter: adam at bewsher dot com ---- 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 )

« previous php.notes (#163934) next »