sarahk
Oct 30th 2005, 6:22 pm
I'm writing a wee link extractor and it works fine for text links but I need it to handle links behind images.
I've got this code if (eregi( ".*<IMG.*ALT=\"(.*)\".*>.*", $link, $out)) {
$curLink['title'] = $out[1];
}
but it picks up everthing from the alt tag to the last "
for example this image
<img alt="Fort Knox in a Box. Visit Lenovo to learn more." src="/us/images/2005/10/102505_T7_Lenovo_Vault.gif" width="152" height="60" border="0" />returnsFort Knox in a Box. Visit Lenovo to learn more." src="/us/images/2005/10/102505_T7_Lenovo_Vault.gif" width="152" height="60" border="0when it should returnFort Knox in a Box. Visit Lenovo to learn more.
Any ideas on how to get the regular expression to behave?
I've got this code if (eregi( ".*<IMG.*ALT=\"(.*)\".*>.*", $link, $out)) {
$curLink['title'] = $out[1];
}
but it picks up everthing from the alt tag to the last "
for example this image
<img alt="Fort Knox in a Box. Visit Lenovo to learn more." src="/us/images/2005/10/102505_T7_Lenovo_Vault.gif" width="152" height="60" border="0" />returnsFort Knox in a Box. Visit Lenovo to learn more." src="/us/images/2005/10/102505_T7_Lenovo_Vault.gif" width="152" height="60" border="0when it should returnFort Knox in a Box. Visit Lenovo to learn more.
Any ideas on how to get the regular expression to behave?