anonīms Posted March 30, 2008 Report Posted March 30, 2008 (edited) 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 March 30, 2008 by anonīms
andrisp Posted March 30, 2008 Report Posted March 30, 2008 Neko nevar saprast. Kodam izmanto CODE nevis QUOTE tagu.
777 Posted March 30, 2008 Report Posted March 30, 2008 (edited) bb2html($data['text']); // apstrada ko tu liec db ar to savu bb2html f-ju un tad liec ieksh db Edited March 30, 2008 by 777
anonīms Posted March 30, 2008 Author Report Posted March 30, 2008 777, tiek apstrādāts. Gan bold, italic, underline, code, quote - iet. Tikai neiet url un url:mailto
andrisp Posted March 30, 2008 Report Posted March 30, 2008 anonīms, tas kods nemaz nevar darboties. str_replace te nederēs priekš linkiem.
andrisp Posted March 30, 2008 Report Posted March 30, 2008 Paskaties kā citi dara: http://www.google.com/search?hl=en&q=bbcode+to+html Un varbūt labāk uzreiz ņem gatavu risinājumu nevis mēģini izgudrot riteni pa jaunam. ;)
Recommended Posts