2012-09-21 178 views

回答

7

這是目前被帶到了一個PHP錯誤:

錯誤報告https://bugs.php.net/bug.php?id=50224

在未來,有可能是功能通過options參數的標誌更嚴格的分型。然而,現在,用引號括起來就足夠了。

+0

感謝您的回覆和鏈接! –

+0

從PHP 7.0開始固定,可用於json_decode的新選項'JSON_PRESERVE_FRACTIONAL_PART' –

0
number_format($number, 2) 

通過那個輸出數字?

1

我不認爲這是可能的!

1
//convert the json to a string before json_decode 
$res = preg_replace('/next_cursor":(\d+)/', 'next_cursor":"\1"', $json); 
0

可以使用JSON_BIGINT_AS_STRING選項,例如:雖然

$json = json_decode($input, true, 512, JSON_BIGINT_AS_STRING); 

小心,這僅適用於PHP 5.4+!