Hi
I have a piece of code which I use to get a string between to tags, although this pulls just one instance I am now trying to do it so if there are more than one instance then I can pull all of them in an array...
function ExtractString($str, $start, $end)
{
$str_low = strtolower($str);
$pos_start = strpos($str_low, $start);
$pos_end = strpos($str_low, $end, ($pos_start + strlen($start)));
if ( ($pos_start !== false) && ($pos_end !== false) )
{
$pos1 = $pos_start + strlen($start);
$pos2 = $pos_end - $pos1;
return substr($str, $pos1, $pos2);
}
}
This is what I use, it works well for pulling one instance but now needing more than one it doesn't work.. am I able to put this into a loop?
$match = ExtractString($html, '<h3 class="post-title">', '</h3>');
The above is what I'd use to extract the string in between <h3 class="post-title"> and </h3> but now there are 10 not 1...
Any help appreciated.. regards