Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Modyfikator links, Jak strtolower
Bastion
post
Post #1





Grupa: Zarejestrowani
Postów: 505
Pomógł: 0
Dołączył: 8.01.2005

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


Witam,

Pisze sobie modyfikator do aktywowania linkow w tekscie, mam problem takiego typu :

w przypadku posiadania tablicy class zawierajacej klasy dla typu odnosnika np :

$class['http'] = 'a_http';
$class['https'] = 'a_https';

a majac w tekscie HtTp://www.some.link.pl

jako protokol zostanie odczytany HtTp , ktory bedzie kluczem do tablicy styli.
w jaki sposob zmusic aby przekonwertowal klucz za pomoca strtolower.
probowalem juz wzystkiego.

  1. <?php
  2.  
  3. function chameleon_modifier_links(&$chameleon, &$input, $class = '', $overwrite = false)
  4. {
  5. $ereg = '/(http|https|ftp|news):(\/\/[[:alnum:]@#%\&_=?\/\.-]+)/ei';
  6.  
  7. if (!empty($class))
  8. {
  9. if (is_array($class))
  10. {
  11. // $_class = " class=\\\"\$class[strtolower(\"$1\")]\\\"";  nie chce dzialac
  12. $_class = " class=\\\"\$class[$1]\\\"";
  13. } else
  14. {
  15. $_class = " class=\\\"".$class."\\\"";
  16. }
  17. } else
  18. {
  19. $_class = '';
  20. }
  21.  
  22. $link = "\"<a".$_class." href=\\\"$1:$2\\\">$1:$2</a>\"";
  23.  
  24. if ($overwrite)
  25. {
  26. $input = preg_replace($ereg, $link, $input);
  27. return $input;
  28. } else
  29. {
  30. $output = preg_replace($ereg, $link, $input);
  31. return $output;
  32. }
  33. }
  34.  
  35. $test = "http://www.vertis.com.pl <br />\n hTTp://www.vertis.com.pl";
  36.  
  37. $style = array('http' => 'styl1');
  38.  
  39. print chameleon_modifier_links($foo, $test, $style);
  40.  
  41. ?>


Ten post edytował Bastion 28.04.2006, 12:36:06


--------------------
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 20.08.2025 - 16:52