Jump to content
php.lv forumi

bbcode


anonīms

Recommended Posts

function bb2html($text) {
//norada, kadi BB koda tagi izmantojami
$bbcode = array("<", ">",
 "[list]", "
[*]", "
[/list]", 
 "[b]", "[/b]", 
 "[u]", "[/u]", 
 "[i]", "[/i]",
 '[color=\"', "[/color]",
 '[size=\"', "[/size]",
 '[url="http://\"',%20"%5b/url"]",
 "[mail=\"", "[/mail]",
 "[.code]", "[/.code]",
 "[.quote]", "[/.quote]",
 "[q]", "[/q]",
 "[br]",
 '"]');
$htmlcode = array("<", ">",
 "<ul>", "<li>", "</ul>", 
 "<b>", "</b>", 
 "<u>", "</u>", 
 "<i>", "</i>",
 "<span style=\"color:", "</span>",
 "<span style=\"font-size:", "</span>",
 '<a href=">', "</a>",
 "<a href=\"mailto:", "</a>",
 "<code>", "</code>",
 "<blockquote>", "</blockquote>",
 "<blockquote>", "</blockquote>",
 "<br />",
 '">');
//parveido bb kodu par html
$newtext = str_replace($bbcode, $htmlcode, $text);

return $newtext;
}

 

textarea rakstu

 

[url=http://php.lv]php.lv[/url]

 

iznākums

 

[url=php.lv]php.lv

 

iekšs db

 

[url=php.lv]php.lv</a>

 

kas par vainu?

Edited by anonīms
Link to comment
Share on other sites

×
×
  • Create New...