Hi all, this is my first post here.
At the moment I am trying to use php to perform what should be a simple action, but it is failing and driving me up the wall.
I have a script which is able to pull a specified number of posts from a phpbb forum (phpbb version 3.05 - latest version), and then display those posts into a php page. The problem I have is that it stripped all the BBCode tags out, and I need URL links, and embedded images to show at the very least. I took out the line of script stripping back the BBCode tags - but here is where I'm getting stuck.
I need to replace the BBCode "[img]" with the HTML equivalent:
Example to replace
[ img ]http://www.google.co.uk/images/nav_logo7.png[ /img ]
(note I put spaces into the IMG tags above so they'd show)
Desired output
<img src="www.google.co.uk/images/nav_logo7.png">
But I encounter a problem in that every single bbcode tag has a string of random numbers after it, like this
[IMG:2j4355]www.google.co.uk/images/nav_logo7.png[/IMG:2j4355]
[url:1y9jihpq]http://www.google.co.uk[/url:1y9jihpq]
I can't use a direct str_replace because of the random jibberish that appears after these bbcode tags, but I need some sort of wildcard to get rid of this.
essentially, looking like this
str_replace("[img:WILDCARD]",'<img src="', $string);
str_replace("[/img:WILDCARD]", '" />", $string);
However I believe that wildcards can't be used in str_replace, and I've tried using preg_replace and it replaces everything inside the [ ] brackets (so if I'm trying to replace a [ URL ] then every single U, R, or L becomes [ URL ]
I need the images and url links to work, as I plan to use this script on a homepage so it'll automatically update when a particular forum thread is updated... so any help is appreciated.