I really don't get the right solution.
My standard img replace code is:
preg_replace('~\[img](.*?)\[/img\]~s','<img src="$1" />',$text);
Of course it works. But im trying to replace the bbcode if width and height is set. But thats optional, so it should work also if only 1 dimension is set or nothing.
The bbcode looks like: [img=12x12]link of the image[/img]
So the bbcode should look like:
preg_replace('~\[img=(.*?)x(.*?)\](.*?)\[/img\]~s','<img width="$1" height="$2" src="$3" />',$text);
I guess I got it wrong. Anybidy knows how to solve this?