FANDOM


Ever wanted to add graphical smileys / emoticons to your website so when someone posts some text, it replaces text-smileys with real ones? Well now you can with this ultra-simple function.

The Code:Edit

function smileys($string) {
$smileys = array(
':)' => '<img class="smiley" src="images/smileys/smile.png" alt=":)" />',
':(' => '<img class="smiley" src="images/smileys/unhappy.png" alt=":(" />',
':D' => '<img class="smiley" src="images/smileys/happy.png" alt=":D" />',
':p' => '<img class="smiley" src="images/smileys/tongue.png" alt=":p" />',
':E' => '<img class="smiley" src="images/smileys/grin.png" alt=":E" />',
';)' => '<img class="smiley" src="images/smileys/wink.png" alt=";)" />',
':3' => '<img class="smiley" src="images/smileys/cat.png" alt=":3" />',
':o' => '<img class="smiley" src="images/smileys/surprised.png" alt=":o" />',
':|' => '<img class="smiley" src="images/smileys/meh.png" alt=":|" />',
':S' => '<img class="smiley" src="images/smileys/confused.png" alt=":S" />',
'B)' => '<img class="smiley" src="images/smileys/cool.png" alt="B)" />',
'>_<' => '<img class="smiley" src="images/smileys/angry.png" alt=">_<" />',
);
return str_ireplace(array_keys($smileys), $smileys, $string);
}

All you need to do is upload the correct smileys to the relative paths on your server.

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.