Jump to content

Getting img urls from a large string


babyrats

Recommended Posts

First a big hi to everyone atphpfreaks.com And a warning, I am pretty new to coding, with only a months worth of php studying. So please if you are able to answer, dumb it down like you are talking to a baby.

 

I am making a review site (to learn) where users can submit their own reviews. If they put a image into a textbox the image URL gets sent to resize.php with the image url in querystring.

 

All the review is held in $review and I was wondering if there is a way for me to grab all URLs in that variable before getting resized so I can also make the resized image a link.

 

E.G <a href="link_to_original.jpg"><img src="resizedImage.jpg" /></a>

 

 

If this is a awful explanation please tell me and I will try to re-write it. Always have been bad at explaining *sigh*

Link to comment
https://forums.phpfreaks.com/topic/188061-getting-img-urls-from-a-large-string/
Share on other sites

Yes the example is what I want to happen.

 

example text:

 

$review = 'This is a example review for test purposes. this will be a resized image

[img=http://image.jpg] (will return <img src="resize?file=image.jpg" />';

 

At the moment the only thing that is done with review is :

 

$imageOpen = str_replace('[img]http://, '<img src="location/resize.php?file=', $string);
$imageClose = str_replace('[/img]', '"/>', $imageOpen);

 

 

but i also what the str_replace to add the link to the original file when the tag is used. Hope this clears things a bit more.

 

thanks for any help in advance.

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.