Jump to content


Photo

Smiley parsing, case sensitive -> case insensitive


  • Please log in to reply
No replies to this topic

#1 Mortier

Mortier
  • Members
  • PipPip
  • Member
  • 27 posts

Posted 29 September 2006 - 06:53 PM

Hello people, I use the following program to make smilies-images out of shortcuts like :) and :P.

<?
function makeSmiley($content)
{
	//bij het toevoegen van een smiley, let wel dat de eerste smiley 0.gif (of 0.jpg) wordt. 
	$smilies = array
	(
		"",	 //0
		":)", //1
		":P", //etc
		":D",
		":(",
		";)",
		":S",
		":'(",
		":@",
	
	);
	//$replace	= de key
	//$smiley 	= de waarde, bijv. :)
	foreach($smilies as $id => $smiley)
	{
		$replace = '<img src="img/smileys/' . $id . '.gif" alt="' . $smiley . '" />';
		$content = str_replace($smiley, $replace, $content); //Search, Replace, Content
	}
	return $content; 
}?>

Unfortunately I can't get it to make :p into an image because it only recognizes the capitalized P.. I've tried everything changing the replace thing do both (strtolower etc..)
But it just won't work...

I can't use PHP 5 functions btw.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users