Page 1 of 1

A little menu speed maker my_htmlentities

Posted: Mon Jun 09, 2008 8:05 am
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;
}