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] 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]); ?> 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
Archived
This topic is now archived and is closed to further replies.