Jump to content

Trying to make my own BB code type thing


scrubbicus

Recommended Posts

So I don't want to install any thing extra but I'm trying to make my own BB code type thing I want them to be able to add text like this [ b ]  [ \b ]

 

what I was trying to do was

 

if ( strstr ( $description , '[ b ]' ) ) str_replace ( '[ b ]' , '<b>' , $description);

 

but that doesn't work. what can I do for this thing I'm trying.

Well your need to set $description back to its new value (with the replacement)

 

ie

<?php
$description = "[b] bold [/b] [i] italic [/i] [u] underline [/u]";
if ( stristr ( $description , '[b]' ) ) $description = str_ireplace ( '[b]' , '<b>' , $description);
?>

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.