Jump to content

Wild Cards in str_replace


maxudaskin

Recommended Posts

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

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.