PHP BBCode Kullanım Örneği - PHP Webmaster bilgi bankası, knowledge base Webmaster Araçları

AnaSayfa > PHP > PHP BBCode Kullanım Örneği
Kategori: PHP
Gönderen: Admin
Tarih: 2009-02-12
Puan: 0   Puan:0 | Katılımcı:0 | Katılımcı : 0
Okunma: 3967
  
 
1 puan 2 puan 3 puan 4 puan 5 puan 6 puan 7 puan 8 puan 9 puan 10 puan

<?
function bb_html ($metin,$mdir='editor'){
$metin = ' '.$metin;
$bb = array(
'(')',
'([t.])',
'/](s.)[/is',
'([ol](.*?)[/ol])is',
'([ul](.*?)[/ul])is',
'([li](.*?)[/li])is',
'([kod](.*?)[/kod])is',
'(

(.*?)

)is',
'([caption](.+?)[/caption])is',
'([left](.*?)[/left])is',
'([center](.*?)[/center])is',
'([right](.*?)[/right])is',
'([renk=(.*?)](.*?)[/renk])is',
'([a(.+?)](.+?))is',
'([img(.+?)])is',
'([b](.+?)[/b])is',
'([strong>(.+?)[/strong])is',
'([i](.+?)[/i])is',
'([strike](.+?)[/strike])is',
'([u](.+?)[/u])is',
'([s](.+?)[/s])is',
'([p(.*?)](.+?)[/p])is',
'([sub](.+?)[/sub])is',
'([sup](.+?)[/sup])is',
'([em](.+?)[/em])is',
'([pre](.+?)[/pre])is',
'([hr(.*?)])is',
'([br])is',
'([br /])is'
);
$html = array(
"'",
'"',
"][",
"<ol>$1</ol>",
"<ul>$1</ul>",
"<li>$1</li>",
'<div id="code">'.highlight_string(html_entity_decode(trim("$1")), true).'</div>',
'<div id="code">'.highlight_string(html_entity_decode(trim("$1")), true).'</div>',
"<caption>$1</caption>",
"<p align="left\\">$1</p>",
"<p align="center\\">$1</p>",
"<p align="right\\">$1</p>",
"<font color="".htmlspecialchars(strip_tags('$1))."\\">$2</font>",
"<a$1 target="_blank\\">$2</a>",
"<img$1>",
"<b>$1</b>",
"<b>$1</b>",
"<i>$1</i>",
"<i>$1</i>",
"<u>$1</u>",
"<s>$1</s>",
"<p$1>$2</p>",
"<sub>$1</sub>",
"<sup>$1</sup>",
"<em>$1</em>",
"<pre>$1</pre>",
"<hr$1 />",
"<br>",
"<br />"
);

$metin = preg_replace($bb,$html,$metin);

return substr($metin, 1);
}

//KULLANIMI
$yazi="<b>php ve mysql</b>";
echo bb_html($yazi);
?>



Yorumlar
Henüz Kimse Yorum Yapmamış, ilk yorumu siz ekleyin!
Yorum Ekleme Aparatı
Yorum Eklemek için lütfen sol menuden giris yapınız..
Toplam 0 yorum listelendi.