Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php] emoty w komentarzach, zielony
Sadu2
post
Post #1





Grupa: Zarejestrowani
Postów: 229
Pomógł: 13
Dołączył: 31.05.2007

Ostrzeżenie: (10%)
X----


Witam,
Mam oto taki kod:

  1. <?php
  2. function smilies($string)
  3.  {
  4.  
  5. $string = str_replace(":)", "<img src="gfx/emoty/smile.gif" alt=":)" />", $string);
  6. $string = str_replace(":(", "<img src="gfx/emoty/sad.gif" alt=":(" />", $string);
  7. $string = str_replace(";)", "<img src="gfx/emoty/wink.gif" alt=";)" />", $string);
  8. $string = str_replace(":D", "<img src="gfx/emoty/grin.gif" alt=":D" />", $string);
  9. $string = str_replace(":p", "<img src="gfx/emoty/pfft.gif" alt=":p" />", $string);
  10. $string = str_replace(":|", "<img src="gfx/emoty/frown.gif" alt=":|" />", $string);
  11. $string = str_replace(":o", "<img src="gfx/emoty/shock.gif" alt=":o" />", $string);
  12. $string = str_replace(":c", "<img src="gfx/emoty/cool.gif" alt=":c" />", $string);
  13. $string = str_replace(":@", "<img src="gfx/emoty/angry.gif" alt=":@" />", $string);
  14.  
  15. return $string;
  16.  }
  17. ?>


Zabardzo nieznam sie na php :( ale chciałbym aby wyświetlały mi sie emoty w komentarzach. Czy tak funkcja jest dobra? W którym miejscu mam ją umieścić aby działała? Dopiero sie ucze i prosze o wyrozumialość.

Pozdrawiam

Ten post edytował Sadu2 3.08.2007, 10:59:59
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
in5ane
post
Post #2





Grupa: Zarejestrowani
Postów: 1 335
Pomógł: 34
Dołączył: 9.11.2005
Skąd: Wrocław

Ostrzeżenie: (10%)
X----


Ja ci pomogę, poczekaj, zaraz coś napiszemy (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)

  1. <?php
  2.  
  3. function emots($txt){
  4.  
  5. $dane = Array
  6. (
  7. => Array
  8. (
  9. 'obraz' => 'emots/zeby.gif'
  10. ),
  11. => Array
  12. (
  13. 'obraz' => 'emots/pytajnik.gif'
  14. ),
  15. => Array
  16. (
  17. 'ikonka' => '!!',
  18. 'obraz' => 'emots/wykrzyknik.gif'
  19. ),
  20. => Array
  21. (
  22. 'obraz' => 'emots/jezyk.gif'
  23. ),
  24. => Array
  25. (
  26. 'obraz' => 'emots/usmiech.gif'
  27. )
  28. );
  29.  
  30.  
  31. $txt = ' '.$txt.' ';
  32. if ( count( $dane ) > 0 )
  33. {
  34. foreach( $dane as $a => $row)
  35. {
  36. $kod = $row['ikonka'];
  37. $obraz = $row['obraz'];
  38. $kod = preg_quote($kod, "/");
  39. $txt = preg_replace( "!$kod!ei", "zmiana_emot('$kod', '$obraz')", $txt );
  40. }
  41. $txt = trim($txt);
  42. return $txt;
  43. }
  44. }
  45.  
  46.  
  47. function zmiana_emot($co="", $naco="")
  48. {
  49. $co = stripslashes($co);
  50. return "<img src="$naco" border=0">";
  51. }
  52.  
  53.  
  54.  
  55.  
  56. ?>


i do folderu emots wbijasz emotki,
a w tym pliku masz u gory kilka testowych emotek dopisanych.

(skrypt nie jest moj, zaporzyczony z internetu)
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: 9.12.2025 - 19:16