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
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);
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.