开发者

replace eurosign in json

开发者 https://www.devze.com 2022-12-15 06:40 出处:网络
Can anyone help me with this one I have this query and only after adding the last one wich is indexed against the euro

Can anyone help me with this one

I have this query and only after adding the last one wich is indexed against the euro I get invalid json.

$url = 'http://www.google.com/finance/info?client=ig&q=goog,yhoo,AMS:TOM2';
$response= json_decode($response,true); 

The only thing different if I directly echo the output is the questionmark in t开发者_StackOverflow中文版he json.

What would I use to replace the eurosign in the json return?, - and hopefully that will solve it.

thanks in adv, Richard


The JSON is valid ISO-8859-1, or Latin1. If your application is using some other encoding, say UTF-8, you need to convert the encoding of the response from Latin1 to UTF-8.


json_encode and json_decode expect in/output to be utf-8. PHP defaults to use iso-8859-1 as charset. So you may have to convert. (Note that the euro sign doesn't exist in iso-8859-1).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号