Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Funkcja na emotikony
debian
post
Post #1





Grupa: Zarejestrowani
Postów: 122
Pomógł: 1
Dołączył: 6.11.2008
Skąd: /etc/passwd

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


Witam, proszę o pomoc przy stworzeniu funkcji która zamienia znaki tupu:
':)' na (images/1.gif)
':D' na (images/2.gif)
':>' (images/3.gif)
itd. No i proszę powiedzieć jak wyował tą funkcję gdzie wkleić itd. Pozdrawiam

Ten post edytował debian 22.11.2008, 22:46:53
Go to the top of the page
+Quote Post
kwiateusz
post
Post #2


Admin Techniczny


Grupa: Administratorzy
Postów: 2 071
Pomógł: 93
Dołączył: 5.07.2005
Skąd: Olsztyn




str_replace" title="Zobacz w manualu PHP" target="_manual
Go to the top of the page
+Quote Post
marcio
post
Post #3





Grupa: Zarejestrowani
Postów: 2 291
Pomógł: 156
Dołączył: 23.09.2007
Skąd: ITALY-MILAN

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


Np:
  1. <?php
  2. function emotki($string) {
  3.  
  4. $emotikony =
  5. array(":[" => "emoty/zly.gif",
  6.  
  7. "**" => "emoty/star.gif",
  8. ":*"
  9. => "emoty/buzi.gif",
  10. ";(" =>
  11. "emoty/sad.gif",
  12. => "emoty/lol.gif",
  13.  ":P" =>
  14. "emoty/jezyk.gif",
  15.  "xD" =>
  16. "emoty/haha.gif",
  17. => "emoty/zeby.gif",
  18.  ";]" =>
  19. "emoty/krzywy.gif",
  20. "=)" =>
  21. "emoty/happy.gif"[img]http://marcio.szu.pl/icon8.gif[/img];
  22.  
  23.  
  24.  
  25. foreach($emotikony as $tekst => $grafika) $string =
  26. str_replace($tekst,'<img src="'.$grafika.'"
  27.  
  28. />',$string);
  29.  
  30. return $string;
  31. }
  32. ?>


Ten post edytował marcio 22.11.2008, 23:17:34
Go to the top of the page
+Quote Post
debian
post
Post #4





Grupa: Zarejestrowani
Postów: 122
Pomógł: 1
Dołączył: 6.11.2008
Skąd: /etc/passwd

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


Dziękuję (IMG:http://forum.php.pl/style_emoticons/default/smile.gif) Ale jak to wywołać.
  1. <?php emotki($string); ?>
(IMG:http://forum.php.pl/style_emoticons/default/questionmark.gif)
Go to the top of the page
+Quote Post
marcio
post
Post #5





Grupa: Zarejestrowani
Postów: 2 291
Pomógł: 156
Dołączył: 23.09.2007
Skąd: ITALY-MILAN

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


  1. <?php
  2. echo($emota);
  3. ?>
Go to the top of the page
+Quote Post
debian
post
Post #6





Grupa: Zarejestrowani
Postów: 122
Pomógł: 1
Dołączył: 6.11.2008
Skąd: /etc/passwd

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


No ale hmmm bo to u mnie to jest taki jakby shoutbox. No i to jakoś muszę ulokować tam.
Go to the top of the page
+Quote Post
marcio
post
Post #7





Grupa: Zarejestrowani
Postów: 2 291
Pomógł: 156
Dołączył: 23.09.2007
Skąd: ITALY-MILAN

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


OMG!! na zmienna pobierana z bazy ktora zawiera tresc wpisu wykonujesz funkcje emotki()
Go to the top of the page
+Quote Post

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: 23.08.2025 - 06:36