Good Morning,
I am working on creating a function that adds http://domain.com to an image/link source. Example:
I have this bit of code in a MySQL database:
here is some random text with an image<img src="http://www.webmaster-talk.com/images/image.png" alt="" /> and a <a href="index.php">link</a> and some more random text.
I would like to turn it into something like this:
here is some random text with an image<img src="http://domain.com/images/image.png" alt="" /> and a <a href="http://domain.com/index.php">link</a> and some more random text.
I am currently using str_replace like this: str_replace("<img src=\"", "<img src=\"http://domain.com", $text);
I have thought about that and I will run into a problem if I am adding http://domain.com to every place even if one already exists (so I would end up with something like this: <img src="http://domain.com/http://domain.com/images/image.png" alt="" />
How do I do this correctly?
Thanks,
Mike
|