Jump to content

Removing bbcode uid (user id)


HaLo2FrEeEk

Recommended Posts

Hey, I'm creating a very simple Content Management System in which I will be pulling out the first 200 characters from every topic in a certain forum for which the subject is "Weekly Update: %" (% being wildcard,) my question is this:  when someone enters some post into the forum, it stores it in the database with a post_id, all bbcode is then appended with a unique uid, it looks something like this:

 

[img:d4fa0dddab]http://claninfectionist.com/images/misc/deadcount21000.png[/img:d4fa0dddab]

 

I want to remove the :% (again, using % as wildcard) from the bbcode to display it normally, I will then do str_replace to replace all bbcode tags with their html counterparts, or at least the more important ones, like bold, italic, underline, image, and link.  Any idea how I can do this?

 

PS. I don't know how to use wildcards in str_replace, but I have seen something of them, will this work with this:

 

$result = str_replace("[img:^(.*)]", "[img]", $result)

 

This example uses just the image tag, but would that work?

 

Edit: This doesn't work, I tried it, and the uid is still there.  Anything else I can try?

Link to comment
https://forums.phpfreaks.com/topic/41728-removing-bbcode-uid-user-id/
Share on other sites

try

<?php
$result ='
[img:868416aced]http://claninfectionist.com/tutorials/photoshop/FireText/untitled18.png[/img:868416aced]';
echo $result1 = preg_replace("[[/]*img:[^\]]+]", "img", $result);
echo "\nor";
echo $result2 = preg_replace("[img:[^\]]+]", "img", $result);
?>

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.