Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

While fetch html content through "preg_match_all" function special char not display proper, how to resolve this?

I'm fetch the html content using below code,

preg_match_all('/<div class="content">(.*?)<\/div>/s', $str, $matches);
echo $matches[1][0];

Content fetched correctly but some special char whit text not display properly like

“response to what?” display as “response to what?â€

but it doesn’t display as but it doesn’t matter. and some blanck space display as Â

how to resolve this issue..?

like image 921
Wiram Rathod Avatar asked Oct 22 '22 13:10

Wiram Rathod


1 Answers

You have unicode issues, try adding this as the first line in your script :

header('Content-Type: text/html; charset=utf-8');
like image 66
Oussama Jilal Avatar answered Oct 24 '22 03:10

Oussama Jilal