I'm having some trouble doing a regular expression. I need code to get all of the alt tags from a page and put them into an array, but it fails miserably:
preg_match_all("'alt=(\")(.*)(\")'i",$html,$alt_tag);
then I was planning to pull all of $alt_tags[2] as the actual text I needed. The problem is, it only works if the alt tag is at the end if the image. For instance, take these two image tags:
<img src="blah" alt="image 1" border="1">
<img alt="image 2" src="blah" border="1">
The first one will match fine, and $alt_tag[2]=image 1. however, in the second example, $alt_tag[2] becomes image 2 src="blah" border="1
for some reason the " won't match unless it is right before the > Very strange, I can't figure out why.
Any guidence would be greatly appreciated