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.

The Code Download

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


Added by JC on 11th November 2007


There are no comments about this snippet.

Post Comment Github Markdown Supported

You must be logged in to post a comment.

Login here to post a comment