Jump to content

[SOLVED] Smilies in text


web_master

Recommended Posts

It'll be better if you use an array:

function parse_smilies($txt)
{
    $smilies_symb = array('', '', '');
    $smilies_html = array('<img src="smilie.gif">', '<img src="sad.gif">', '<img src="wink.gif">');

    $txt = str_replace($smilies_symb, $smilies_html, $txt);

    return $txt;
}

$s = "this is some text with a smilie face ";

$s = parse_smilies($s);

echo $s;

another example

<?php
$code[] = "";
$img[]="<img src='frown.gif'>";

$code[] = "";
$img[]="<img src='happy.gif'>";

$code[] = "";
$img[]="<img src='poke.gif'>";

$s = "this is some text with a smilie face ";
$s = str_replace($code, $img, $s);
echo $s;
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.