Wednesday, May 18, 2016

How To Replace Smart Quotes Microsoft Encoded Quotes In PHP

Many people have emailed and asked me about how can they replace those Smart Quotes using PHP.Well the answer is that there are many ways to do so.In this example I will explain it with a function that will do the job.

Use the function below to replace Smart Quotes easily.

function convert_smart_quotes($string) 
{
$search = array(chr(145),
chr(146),
chr(147),
chr(148),
chr(151));

$replace = array("",
"",
",
",
-);

return str_replace($search, $replace, $string);
Thats it! The function should work perfectly.Some minor changes may be needed here and there in this php script to suit your specific needs in particular.Hope you liked this piece of code.

Enjoy!