-1

I want to convert the [img] bbcode of SMF to HTML, it looks like this:

[img width=600 height=300]url[/img]

My script is this, but doesn't work, what's wrong?

$text = preg_replace("/\[img  width=(.*) height=(.*)\](.*)\[\/img\]/Usi", "<img src=\"\\3\" class=\"image\" style=\"width:\\1; height:\\2\" />", $text);
Ender Null
  • 19
  • 8
  • This question is has nothing to do with greediness. It is a typo in your pattern. You have two whitespaces before `width`, but your input only has one. Proof: https://3v4l.org/aTUbA Voting to close as **Off-topic: Typo** instead of answering. – mickmackusa Mar 06 '20 at 06:15

1 Answers1

-1

Your wild cards are being greedy. Use .*? Instead of .*

Richard Brown
  • 11,346
  • 4
  • 32
  • 43