[PHP] – json_decode() for big integers ?>

[PHP] – json_decode() for big integers

json_decode() is use for decode a json text to object (or array) in PHP. For normal case, below code will decode a json string to an array in PHP:

But if the json contain a really big integers then the problem will be appear, take a look at below code:

The result will be:

So the solution here is we need to tell the json_decode function that we need to convert the big integers to string. Something like this:

And now it’s better:

 

Have fun!

 

Ref: http://php.net/manual/en/function.json-decode.php

Leave a Reply

Your email address will not be published. Required fields are marked *