Facebook

Wednesday, September 2, 2015

How to replace Microsoft-encoded quotes in PHP

Scenario: I need to replace Microsoft Word version of single and double quotations marks (“ ” ‘ ’) with regular quotes (' and ") due to an encoding issue in my application.

$search = array(
         chr(145),
         chr(146),
         chr(147),
         chr(148),
         chr(151)
);
$replace = array(
         "'",
         "'",
         '"',
         '"',
         '-'
 );
 return str_replace($search, $replace, $value);
Reference: http://stackoverflow.com/a/1262060/345721

No comments:

Post a Comment