A little menu speed maker my_htmlentities

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
pb
Forum Members
Forum Members
Posts: 27
Joined: Sun Jun 01, 2008 8:41 pm

A little menu speed maker my_htmlentities

Post by pb »

Used in many parts and this is the speed version (in misc.functions.php)

Code: Select all


function my_htmlentities($val, $convert_single_quotes = false)
{
	if ($val == "")  return "";
	
	$search=array(" ","&","<!--","-->",">", "<","\"","!","'");
  $replace=array(' ',"&","<!--","-->",">" ,"<",""","!","'" );
  $val=str_replace($search,$replace,$val);
  $val = preg_replace( "/<__script__/i"  , "<__script__"   , $val );
  $val = preg_replace( "/\\$/"      , "$"        , $val );
  if ($convert_single_quotes)
		$val = str_replace(array("\\'","'"),array("&apos;","&apos;"),$val);

	return $val;
}

Post Reply

Return to “Tips and Tricks”