
[php:1:52d8ccad3a]<?php
function bbCode ($text) { // bbCode()
$text = nl2br($text);
// usuwa puste znaczniki
$text = str_replace("[ b ][/ b ]", "", $text);
// musialem dodac space zeby forum nie parsowalo
$text = str_replace("[ i ][/ i ]", "", $text);
$text = str_replace("[ u ][/ u ]", "", $text);
$text = str_replace("[img][/img]", "", $text);
$text = str_replace("", "", $text);
// zamienia znaczniki na html
$text = str_replace("[ b ]", "<b>", $text);
$text = str_replace("[/ b ]", "</b>", $text);
$text = str_replace("[ i ]", "<i>", $text);
$text = str_replace("[/ i ]", "</i>", $text);
$text = str_replace("[ u ]", "<u>", $text);
$text = str_replace("[/ u ]", "</u>", $text);
$text = str_replace("[img]", '<img src="', $text);
$text = str_replace("[/img]", '" alt="" align="left">', $text);
$text = str_replace("[url=", '<a href="', $text);
$text = str_replace("[/url]", "</a>", $text);
// zamiana kolorow
$text = str_replace("[color=", '<span style="color: ', $text);
$text = str_replace("[/color]", "</span>", $text);
// zmiana wielkosci textu
$text = str_replace("[size=", '<span style="font-size: ', $text);
$text = str_replace("[/size]", "</span>", $text);
$text = str_replace("]", '">', $text);
/* to robi najwiecej zamieszania, np.
gdy w stringu (konkretnie tresci newsa)
wystepuja nawiasy kwadratowe nie zwiazane ze znacznikami
*/
return $text;
}
?>[/php:1:52d8ccad3a]
update: chyba preg_match

