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----


Utwórz powiedzmy plik:
emotikony.php i wklej to tam

Teraz w pliku, w którym chcesz, aby były te emotki robisz:
  1. <?php
  2. include("emotikony.php");
  3. ?>


I żeby wyświetlane komentarze miały emotki robisz:
zamiast:
  1. <?php
  2. echo 'pole z bazy, cos tam';
  3. ?>

coś takiego:
  1. <?php
  2. echo emotki ('pole z bazy, cos tam');
  3. ?>



I każdą emotkę musisz dopisać do pliku, a mianowicie:
  1. <?php
  2. => Array
  3. (
  4. 'ikonka' => '<foch>', // co trzeba wpisać by wyświetlić
  5. 'obraz' => 'emots/foch.gif' // ścieżka do emotki
  6. )
  7. ?>

(tylko, że jeżeli chcesz dodawać każdą następną emotkę, to musisz zmieniać cyferkę o jeden i dodawać przecinek po przedostatniej emotce).



Pozdro (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)

Ten post edytował in5ane 3.08.2007, 11:25:03
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: 11.12.2025 - 08:46