Jump to content
Nytro

[ PHP ] Simple BBCode

Recommended Posts

Posted
<?php

function BBcode($texto){
$a = array(
"/\[i\](.*?)\[\/i\]/is",
"/\[b\](.*?)\[\/b\]/is",
"/\[u\](.*?)\[\/u\]/is",
"/\[img\](.*?)\[\/img\]/is",
"/\[url=(.*?)\](.*?)\[\/url\]/is",
"/\[size=(.*?)\](.*?)\[\/size\]/is",
);
$b = array(
"<i>$1</i>",
"<b>$1</b>",
"<u>$1</u>",
"<img src=\"$1\" />",
"<a href=\"$1\" target=\"_blank\">$2</a>",
'<font size=$1>$2</font>',
);
$texto = preg_replace($a, $b, $texto);
$texto = nl2br($texto);
return $texto;
}


if(isset($_GET['txt'])) {

echo "Has introducido: ".bbcode($_GET['txt']);

}

?>

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.   Paste as plain text instead

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