BOM头是UTF-8来告诉编辑器:我是UTF8编码。它的编码是\xEF\xBB\xBF

但是PHP在设计之初并没有考虑到BOM头的问题,所以在编解码的时候很容易出现问题
    
$result = trim($result, "\xEF\xBB\xBF");
print_r(json_decode($result, true));
exit;

 

还有一种比较矬:
1
2
3
4
5
    
$result = @iconv("UTF-8", "GBK//IGNORE", $result);
$result = @iconv("GBK", "UTF-8//IGNORE", $result);
 
print_r(json_decode($result, true));
exit;

 

起点在哪,或许选择不了。重要的是,你追求的终点在哪!