Saturday, March 14, 2009

Convert Smart Quotes back to normal

Convert Smart Quotes back to normal

Description PHP Replaces right side, and left side quotes and double quote characters with normal single and double quotes. Useful for interpreting text from a WYSIWYG editor, when someone has pasted content from Word.

<?php
function convert_smart_quotes($string) {
//converts smart quotes to normal quotes.
$search = array(chr(145), chr(146), chr(147), chr(148), chr(151));
$replace = array("'", "'", '"', '"', '-');
return str_replace($search, $replace, $string);
}
?>

No comments: