Jump to content

BBC Code <br \> question


UnknownPlayer

Recommended Posts

I use this bbc code.

This is bbccode_function.php:

<?php

function bbcode($input){
    $input = strip_tags($input);
    $input = htmlentities($input);
    
    $search = array(
                '/\[b\](.*?)\[\/b\]/is',
                '/\[i\](.*?)\[\/i\]/is',
                '/\[u\](.*?)\[\/u\]/is',
                '/\[img\](.*?)\[\/img\]/is',
                '/\[url=http://(.*?)\](.*?)\[\/url\]/is',
                '/\[font color=(.*?) size=(.*?) face=(.*?)\](.*?)\[\/font\]/is',
                '/\[h1\](.*?)\[\/h1\]/is',
                '/\[special\](.*?)\[\/hat\]/is'
    );
    
    $replace = array(
                '<b>$1</b>',
                '<i>$1</i>',
                '<u>$1</u>',
                '<img src="$1">',
                '<a href="$1">$2</a>',
                '<font style="color:$1;font-size:$2;font-face:$3">$4</font>',
                '<h1>$1</h1>',
                '<a href="http://google.com" style="font-size:32pt;text-decoration:blink;color:#FF0099">$1</a>'
    );
    
    return preg_replace($search,$replace,$input);
}

?> 

 

And this is test page:

<?php
include "bbcode_function.php";

$var = "[b]text[/b]";

echo bbcode($var);
?> 

 

But when i put <br \> code in $var, it does not goes to new row.

I use this bbc code in textarea, and i need when i go in new row in textarea to use that bbc code, or somehow to make that work :S

How can i do that?

Link to comment
https://forums.phpfreaks.com/topic/213526-bbc-code-question/
Share on other sites

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.