Changing URLs from Relative to Absolute
| From: | Tom Chubb | Date: | Mon, 30 Jul 2007 12:16:05 +0000 |
| Subject: | Changing URLs from Relative to Absolute | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-259804@lists.php.net to get a copy of this message | ||
Dear list,
I was recently trying to write a script where a user copy and pastes their
HTML code to display something on a listings site and tried to find a way to
change the URL of an image from relative to absolute.
For example <img src="images/1.jpg"> becomes <img = src="
http://domain.com/images/1.jpg">.
That is easy enough and I created a regexp, but I found that some people
call the img tag differently such as:
<img a="A photo" src="images/1.jpg">
Does anyone have experience of this? How can I create a regexp that will
find it in every case?
Thanks in advance.
Tom
--
Tom Chubb
tomchubb@gmail.com