Простая функция bb-кодов
Mod
:
Простая функция bb-кодов
20 Сент 2020
<?php
function bb_code($text){
$text = preg_replace("/<strong>(.*?)</strong>/is", "<strong>1</strong>", $text);
$text = preg_replace("/<em>(.*?)</em>/is", "<i>1</i>", $text);
$text = preg_replace("/<span style="text-decoration:underline;">(.*?)</span>/is", "<u>1</u>", $text);
$text = preg_replace("/[s](.*?)[/s]/is", "<s>1</s>", $text);
$text = preg_replace('#[url]([rn]*)(http://|ftp://|https://|ftps://)([^s'"]*?)([rn]*)[/url]#sie', "'<a href='23' target='_blank' title='23'>'.(strlen('23')>30?substr('23', strlen('23')-10, strlen('23')):'').'</a>'", $text);
$text = preg_replace('#[url]([rn]*)([^s'"]*?)([rn]*)[/url]#sie', "'<a href='http://2' target='_blank' title='2'>'.(strlen('2')>30?substr('2', strlen('2')-10, strlen('2')):'').'</a>'", $text);
$text = preg_replace('#<a href="([rn">*)(http://|ftp://|https://|ftps://)([^s'"]*?)](.*?)([rn]*)</a>#si', '<a href='23' target='_blank' title='23'>4</a>', $text);
$text = preg_replace('#<a href="([rn">*)([^s'"]*?)](.*?)([rn]*)</a>#si', '<a href='http://2' target='_blank' title='2'>3</a>', $text);
return $text;
}?>
Последний раз редактировалось Mod
20 Сент 2020