Co zrobić, żeby funkcja hightlight_string, była używana tylko między znacznikami <code></code>?
Funkcja, która u mnie zamienia BBCode na HTML to:
<?php
function replace($text) {
$text = preg_replace("#[img](.*?)[/img]#si",'<img src="1" alt="Kacper Kołodziej">',$text); $text = preg_replace("#[link=(http.*?)](.*?)[/link]#si",'<a target="_blank" href="1">2</a>',$text); $text = preg_replace("#[link=(.*?)](.*?)[/link]#si",'<a target="_blank" href="http://1">2</a>',$text); $text = preg_replace("#[url=(.*?)](.*?)[/link]#si",'<a target="_blank" href="http://1">2</a>',$text); $text = preg_replace("#[link](.*?)#si",'<a target="_blank" href="http://1">1</a>', $text); $text = preg_replace("#[link](http.*?)[/url]#si",'<a target="_blank" href="1">1</a>', $text); $text = preg_replace("#[h2](.*?)[/h2]#si",'<h2>1</h2>',$text); $text = preg_replace("#[h1](.*?)[/h1]#si",'<h1>1</h1>',$text); $text = preg_replace("#[link](http.*?)[/link]#si",'<a href="1">1</a>',$text); $text = preg_replace("#[link](.*?)[/link]#si",'<a target="_blank" href="http://1">1</a>',$text); }
?>