Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]highlight_string między znacznikami
kacpero1094
post
Post #1





Grupa: Zarejestrowani
Postów: 87
Pomógł: 0
Dołączył: 22.12.2008

Ostrzeżenie: (0%)
-----


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:
  1. <?php
  2. function replace($text) {
  3. $text=htmlspecialchars($text);
  4. $text = nl2br($text);
  5. $text = preg_replace("#(.*?)#si",'<b>1</b>',$text);
  6. $text = preg_replace("#(.*?)#si",'<i>1</i>',$text);
  7. $text = preg_replace("#(.*?)#si",'<u>1</u>',$text);
  8. $text = preg_replace("#[img](.*?)[/img]#si",'<img src="1" alt="Kacper Kołodziej">',$text);
  9. $text = preg_replace("#[link=(http.*?)](.*?)[/link]#si",'<a target="_blank" href="1">2</a>',$text);
  10. $text = preg_replace("#[link=(.*?)](.*?)[/link]#si",'<a target="_blank" href="http://1">2</a>',$text);
  11. $text = preg_replace("#[url=(.*?)](.*?)[/link]#si",'<a target="_blank" href="http://1">2</a>',$text);
  12. $text = preg_replace("#(.*?)#si",'<a target="_blank" href="1">1</a>', $text);
  13. $text = preg_replace("#[link](.*?)#si",'<a target="_blank" href="http://1">1</a>', $text);
  14. $text = preg_replace("#[link](http.*?)[/url]#si",'<a target="_blank" href="1">1</a>', $text);
  15. $text = preg_replace("#[h2](.*?)[/h2]#si",'<h2>1</h2>',$text);
  16. $text = preg_replace("#[h1](.*?)[/h1]#si",'<h1>1</h1>',$text);
  17. $text = preg_replace("#[link](http.*?)[/link]#si",'<a href="1">1</a>',$text);
  18. $text = preg_replace("#[link](.*?)[/link]#si",'<a target="_blank" href="http://1">1</a>',$text);
  19. $text = preg_replace("#[code](.*?)[/code]#si",'<code>' . highlight_string('1') . '</code>',$text);
  20. }
  21. ?>


Ten post edytował kacpero1094 31.07.2009, 15:11:29
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 25.09.2025 - 20:00