note 68456 added to ref.strings
| From: | heavyraptor at osu1 dot php dot net | Date: | Thu, 27 Jul 2006 15:17:00 +0000 |
| Subject: | note 68456 added to ref.strings | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-115272@lists.php.net to get a copy of this message | ||
I think that
administrador(ensaimada)sphoera(punt)com's function is
too complicated. It's easier with regular expressions.
So I made this function, it isn't really the same,
it's even better because it returns an array with all the
matches found
If there are no matches, false is returned.
<?php
// bool/array str_between( string str, string
start_str, string end_str )
function str_between($str,$start,$end) {
if (preg_match_all('/' . preg_quote($start) . '(.*?)' . preg_quote($end) .
'/',$str,$matches)) {
return $matches[1];
}
// no matches
return false;
}
?>
Enjoy
----
Server IP: 194.153.94.10
Probable Submitter: 84.73.156.125
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/ref.strings.php
Edit -- http://master.php.net/note/edit/68456
Del: integrated -- http://master.php.net/note/delete/68456/integrated
Del: useless -- http://master.php.net/note/delete/68456/useless
Del: bad code -- http://master.php.net/note/delete/68456/bad+code
Del: spam -- http://master.php.net/note/delete/68456/spam
Del: non-english -- http://master.php.net/note/delete/68456/non-english
Del: in docs -- http://master.php.net/note/delete/68456/in+docs
Del: other reasons-- http://master.php.net/note/delete/68456
Reject -- http://master.php.net/note/reject/68456
Search -- http://master.php.net/manage/user-notes.php