I have a function which extracts the content between 2 strings. I use it to extract specific information between html tags . However it currently works to extract only the first match so I would like to know if it would be possible to improve it in a such way to extract all the matches and provide them in an array .. similar with preg_match_all function .
function get_between($content,$start,$end){
$r = explode($start, $content);
if (isset($r[1])){
$r = explode($end, $r[1]);
return $r[0];
}
return '';
}
Version with recursion.
Version with loop.
Version with array_map for PHP 5.2 and earlier.
Version with array_map for PHP 5.3.