I met some trouble in php json decode number.
$json = '[{"num":123456789011121314},{"num":1516171819202122232425}]';
$number = json_decode($json);
foreach($number as $num){
echo $num->num.'<br />';
//echo (int)$num->num.'<br />';
}
this will get:
1.23456789011E+17
1.5161718192E+21
Also (int) do a wrong callback. And how to get the orignal number? Thanks.
I need
123456789011121314
1516171819202122232425
If you’re using PHP 5.4 or later, you can do this:
$number = json_decode($json, true, 512, JSON_BIGINT_AS_STRING);Which will represent those large numbers as strings instead of ints. If you have access to the code generating the json, you could also encode the numbers as strings.