Okay, as part of a project going on - this person wants me to take all image tags within a certain HTML string given and preg_replace it so the width is set to a certain static number. Also, a link is to be placed around the image tag in order to make it clickable and show a pop-up of its full size.
I have tried using preg_replace and have read through most of its documentation on php.net. The issue is that when the pattern looks for a match, it will go for the LAST occurence of the text (closing arrow of the tag)
and take out much more than it’s bargained for. There is no width tag defined in these tags, so it’d be pretty easy to add that and the link afterwards.
$p_post = preg_replace("|<img src="(.*)"(.*)\/\>|si","CHECK",$p_post);
So here’s my goals with this line of code:
Grab the URL of the image’s src.
Change it so it’s not looking for the LAST occurence of **/>