maxudaskin Posted March 31, 2008 Share Posted March 31, 2008 Is it possible? If not, is there another way to do it? What I want to do is if <img src="someurl.com/image.jpg" /> is found (the url would vary) to getimagesize("someurl.com/image.jpg"). To do this, we need to extract the URL... is it possible? <?php $smilies = array("[img=","]"); $locations = array('<img src="','" />'); echo str_replace($smilies,$locations,nl2br($text)); ?> $text might be Hey, I found a cool pic! [img=http://www.url.com/image.jpg] Quote Link to comment https://forums.phpfreaks.com/topic/98734-wild-cards-in-str_replace/ Share on other sites More sharing options...
sasa Posted March 31, 2008 Share Posted March 31, 2008 try <?php $text = 'Hey, I found a cool pic! [img=http://www.url.com/image.jpg] bla [img=http://www.url2.com/image2.jpg]'; preg_match_all('/\[img\](.+?)\[\/img\]/', $text, $url); print_r($url[1]); ?> Quote Link to comment https://forums.phpfreaks.com/topic/98734-wild-cards-in-str_replace/#findComment-505364 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.