With PHP, how can I isolate the contents of the src attribute from $foo? The end result I\'m looking for would give me just \"http://example.com/img/image.jpg\"
You can go around this problem using this function:
function getTextBetween($start, $end, $text)
{
$start_from = strpos($text, $start);
$start_pos = $start_from + strlen($start);
$end_pos = strpos($text, $end, $start_pos + 1);
$subtext = substr($text, $start_pos, $end_pos);
return $subtext;
}
$foo = '
';
$img_src = getTextBetween('src="', '"', $foo);