Evo nekoliko nacina za BB kodove
BY marko
(a2-soft.com)
<?php
function bbcode_format($text)
{
$text = htmlentities($text);
$search = array('/\[b\](.*?)\[\/b\]/is', '/\[i\](.*?)\[\/i\]/is');
$replace = array('<b>$1</b>', '<i>$1</i>');
$str = preg_replace ($search, $replace, $text);
return $str;
}
echo bbcode_format('[b]test bold[/b]...[i]test italic[/i] itd itd');
?>
by seti
$trazi= array("/n");
$zameni= array("<br />");
str_replace ($trazi, $zameni, $text);
By Akon (edan moj ortak

)
<?
function BBCode($text)
{
$text = htmlspecialchars($text);
$text = preg_replace("/\[b\](.*?)\[\/b\]/i","<b>\\1</b>", $text);
$text = preg_replace("/\[i\](.*?)\[\/i\]/i","<i>\\1</i>", $text);
$text = preg_replace("/\[u\](.*?)\[\/u\]/i","<u>\\1</u>", $text);
$text = preg_replace("/\[big\](.*?)\[\/big\]/i","<big>\\1</big>", $text);
$text = preg_replace("/\[small\](.*?)\[\/small\]/i","<small>\\1</small>", $text);
$text = preg_replace("/\[url\=(.*?)\](.*?)\[\/url\]/is","<a href=\"$1\">$2</a>",$text);
$text = str_replace("[br/]", "<br />", $text);
return $text;
}
$Go = $_GET["Go"];
if($Go = "Post"){
$FormText = BBCode($_POST["FormText"]);
echo "Text je: " . $FormText;
} else {
?>
<div>
<form action="?Go=Post" method="post">
<textarea name="FormText" rows="10"><?= $FormText; ?></textarea><br />
<input type="submit" />
</form>
</div>
<?
}
?>
pa sad vi vidite sta vam odgovara
