note 68456 deleted from ref.strings by googleguy
| From: | googleguy@php.net | Date: | Tue, 22 Oct 2013 06:47:04 +0000 |
| Subject: | note 68456 deleted from ref.strings by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-196640@lists.php.net to get a copy of this message | ||
Note Submitter: heavyraptor
----
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