Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [Funkcja] Emotikony, funkcja php 4 i 5
Rafał 40x
post
Post #1





Grupa: Zarejestrowani
Postów: 26
Pomógł: 0
Dołączył: 2.05.2006

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


Kod:

  1. <?php
  2.  
  3. function emots ( $text ) {
  4.  
  5. if ( ! is_dir ( 'emots' )) {
  6.  
  7. echo "Brak katalogu z emotikonami.";
  8.  
  9. } else {
  10.  
  11. $_POST['text'] = $text;
  12.  
  13. $text = str_replace (":D", "<img src='emots/d.gif'>", $text);
  14. $text = str_replace (":)", "<img src='emots/u.gif'>", $text);
  15. $text = str_replace (":/", "<img src='emots/k.gif'>", $text);
  16.  
  17. return $text;
  18.  
  19. }
  20. }
  21.  
  22. ?>


Przykład użycia:

(Przed użyciem skryptu należy stworzyć katalog emots.)

  1. <?php
  2.  
  3. echo '<form action="index.php" method="post">';
  4. echo '<textarea name="text"></textarea><br />';
  5. echo '<input type="submit"></form>';
  6.  
  7. echo emots ( $text ); 
  8.  
  9. ?>


Wpisujemy w textarea np.:
Kod
To jest pewien text :D.

Zamiast :D widzimy emota.



Piszcie co dodać, co zmienić itp.

Pozdrawiam,
Rafał.

Ten post edytował Rafał 40x 2.05.2006, 12:09:24
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: 22.08.2025 - 03:53