Smilies mit PHP umwandeln fürs Gästebuch

finnex

Erfahrenes Mitglied
Hallo,
ich will gerne in mein Gästebuch Smilies einfügen können:

Ich habe es schon hinbekommen, dass ich den Smilie Tag in das Textfeld bekomme.
HTML:
<a onClick="document.form1.text.value+=':-)';"><img src="images/heul.gif"></a>

Doch nun werden mit die Smilies nur als Text angezeigt!

Wie muss/kann ich jetz mit PHP die Smilies mit der Grafik Datei austauschen


Mfg finnex
 
in eine Textarea/box kannst du kein Smilie anzeigen..
//Edit: Upps, sorry, hab mich verlesen ^^.. Wie auch Maik sagt, der Pfad wird nicht stimmen.. Versuch mal den kompletten anzugeben..
Mfg
Philipp
 
Zuletzt bearbeitet:
Ich hab mir mal selber so ne Art BBCode Light gebaut ist eigentlich ziemlich einfach.
Ich hoffe das ich dich richtig verstanden habe und dir das weiter hilft.

PHP:
function cfl2html($text){
	$text = str_replace ( '[ center]', '<div align="center">', $text );
	$text = str_replace ( '[ /center]', '</div>', $text );
	$text = str_replace ( '[ right]', '<div align="right">', $text );
	$text = str_replace ( '[ /right]', '</div>', $text );
	$text = str_replace ( '[ left]', '<div align="left">', $text );
	$text = str_replace ( '[ /left]', '</div>', $text );
	$text = str_replace ( '[ justify]', '<div align="justify">', $text );
	$text = str_replace ( '[ /justify]', '</div>', $text );
	
	$text = str_replace ( '[ strong]', '<strong>', $text );
	$text = str_replace ( '[ /strong]', '</strong>', $text );
	$text = str_replace ( '[ em]', '<em>', $text );
	$text = str_replace ( '[ /em]', '</em>', $text );
	$text = str_replace ( '[ h2]', '<h2>', $text );
	$text = str_replace ( '[ /h2]', '</h2>', $text );
	
	$text = str_replace ( '[ red]', '<div style="color:red;">', $text );
	$text = str_replace ( '[ /red]', '</div>', $text );
	$text = str_replace ( '[ black]', '<div style="color:black;">', $text );
	$text = str_replace ( '[ /black]', '</div>', $text );
	$text = str_replace ( '[ green]', '<div style="color:green;">', $text );
	$text = str_replace ( '[ /green]', '</div>', $text );
	$text = str_replace ( '[ blue]', '<div style="color:blue;">', $text );
	$text = str_replace ( '[ /blue]', '</div>', $text );
	$text = str_replace ( '[ PerfectBodyColor]', '<div style="color:#7C003F;">', $text );
	$text = str_replace ( '[ /PerfectBodyColor]', '</div>', $text );
	
	$text = str_replace ( '[ overline]', '<div style=" text-decoration:overline;">', $text );
	$text = str_replace ( '[ /overline]', '</div>', $text );
	$text = str_replace ( '[ line-through]', '<div style=" text-decoration:line-through;">', $text );
	$text = str_replace ( '[ /line-through]', '</div>', $text );
	$text = str_replace ( '[ underline]', '<div style=" text-decoration:underline;">', $text );
	$text = str_replace ( '[ /underline]', '</div>', $text );

	$text = str_replace ( ':)', '<image src="images/emoicons/icon_smile.gif" alt="Smile" />', $text );
	$text = str_replace ( ':-)', '<image src="images/emoicons/icon_smile.gif" alt="Smile" />', $text );
	$text = str_replace ( ':o)', '<image src="images/emoicons/icon_smile.gif" alt="Smile" />', $text );
	$text = str_replace ( ':P', '<image src="images/emoicons/icon_razz.gif" alt="Smile" />', $text );
	$text = str_replace ( ':-P', '<image src="images/emoicons/icon_razz.gif" alt="Smile" />', $text );
	$text = str_replace ( ';-)', '<image src="images/emoicons/icon_wink.gif" alt="Smile" />', $text );
	$text = str_replace ( ';)', '<image src="images/emoicons/icon_wink.gif" alt="Smile" />', $text );
	
	return $text;
	}
 
danke für die antwort habe es grad auch rausbekommen was der fehler war....

musste diesen code einfügen:
$array2[$text] = str_replace(":)", "<img src=\"images/heul.gif\"/>", $array2[$text]);

jetzt klappts...


Finnex
 
Zurück