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