I am trying to remove some special/weird characters from a PHP array.
The data comes in as a JSON
with html
like this:
<table class=\"MsoNormalTable\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"728\" style=\"width:545.75pt; margin-left:-1.7pt; border-collapse:collapse\">\r\n<tbody>\r\n<tr style=\"height:15.0pt\">\r\n<td width=\"303\" valign=\"top\" style=\"width:227.0pt; border:solid windowtext 1.0pt; padding:0cm 5.4pt 0cm 5.4pt; height:15.0pt\">\r\n<p class=\"MsoNormal\" style=\"line-height:115%\"><span style=\"font-family:"Calibri","sans-serif"; color:black\">Policy number:<\/span><\/p>\r\n<\/td>\r\n<td width=\"425\" nowrap=\"\" valign=\"bottom\" style=\"width:318.75pt; border:solid windowtext 1.0pt; border-left:none; padding:0cm 5.4pt 0cm 5.4pt; height:15.0pt\">\r\n<p class=\"MsoNormal\" style=\"line-height:115%\"><span style=\"font-family:"Calibri","sans-serif"; color:black\"> LAP3_MC_2011030004 \r\n<\/span><\/p>\r\n<\/td>\r\n<\/tr>\r\n<tr style=\"height:15.0pt\">\r\n<td width=\"303\" nowrap=\"\" valign=\"bottom\" style=\"width:227.0pt; border:solid windowtext 1.0pt; border-top:none; padding:0cm 5.4pt 0cm 5.4pt; height:15.0pt\">
I am reading the data and filtering out the pars i need using DomCrawler
and the output is :
string(4) "�Mr�"
I have tried :
iconv("UTF-8", "ISO-8859-1//TRANSLIT", $l->nodeValue);
But it doesn't remove the weird diamond characters.
Any idea how to fix this??
Try
iconv("UTF-8", "ISO-8859-1//IGNORE", $l->nodeValue);
OR
mb_convert_encoding ( $l->nodeValue, "ISO-8859-1", "UTF-8" )