This question already has an answer here:
I need to match something from content get the url from it and completely change the matched item. here is my content look like:
$content = "A quick brown fox {img:https://imageurl.com/fox.jpg} jumps over the lazy dog {img:https//:imageurl.com/dog.jpg}.";
I need it like this:
echo $content;
A quick brown fox <img src='https://imageurl.com/fox.jpg' style='width:100%' /> jumps over the lazy dog. <img src='https//:imageurl.com/dog.jpg' style='width:100%' />;
I can get the links using preg_match_all("/\{img:(.*?)\}/", $text, $matches);
but don't know how to replace it.
Thanks in advance;
</div>
The solution is the data cutting between {}.
Try this:
$result = preg_replace("#\{img:(.*)\}#U",'<img src=\'$1\' style=\'width:100%\' />',$content);