note 41152 modified in function.htmlentities by danbrown

From: Date: Sun, 17 May 2009 17:07:25 +0000
Subject: note 41152 modified in function.htmlentities by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-154943@lists.php.net to get a copy of this message
htmlentites is a very handy function, but it fails to fix one thing which I deal with alot: word 'smart' quotes and emdashes. The below function replaces the funky double quotes with &quot;, funky single quotes with standard single quotes and fixes emdashes. <?php function CleanupSmartQuotes($text) { $badwordchars=array( chr(145), chr(146), chr(147), chr(148), chr(151) ); $fixedwordchars=array( "'", "'", '&quot;', '&quot;', '&mdash;' ); return str_replace($badwordchars,$fixedwordchars,$text); } ?> --was-- htmlentites is a very handy function, but it fails to fix one thing which I deal with alot: word 'smart' quotes and emdashes. The below function replaces the funky double quotes with &quot;, funky single quotes with standard single quotes and fixes emdashes. function CleanupSmartQuotes($text) { $badwordchars=array( chr(145), chr(146), chr(147), chr(148), chr(151) ); $fixedwordchars=array( "'", "'", '&quot;', '&quot;', '&mdash;' ); return str_replace($badwordchars,$fixedwordchars,$text); } http://php.net/manual/en/function.htmlentities.php

« previous php.notes (#154943) next »