I would like to replace all spaces in the image tags of a html text.
Example:
<img src="photo 1.jpg" />
to
<img src="photo%201.jpg"/>
I didn’t find a soultion with preg_replace, but it may be a simple regexp line.
Thanks!
Edit: Sorry guys, my description was not very clear. So, I have a full html page and I only want to replace inside the img tags. I can’t use urlencode here as it encodes the other stuff as well.
The space is represented by a %20 in the url but there are other chars that you might want to have converted for other images so you should use the general urlencode function instead of using a “simple regex” as stated in the OP.