w3resource
php Programming Exercies

PHP JSON Exercises : Decode larger integers

PHP JSON: Exercise-2 with Solution

Write a PHP script to decode large integers.

Sample integer :
{"number": 123456789012345678901234567890}

Sample Solution:

PHP Code:

<?php
$json = '{"number": 123456789012345678901234567890}';
var_dump(json_decode($json));
?>

Sample Output:

object(stdClass)#1 (1) {                                            
  ["number"]=>                                                      
  float(1.2345678901235E+29)                                        
}

Flowchart :

Flowchart: Decode larger integers

PHP Code Editor:

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a PHP script to decode a JSON string.
Next: Write a PHP script to get JSON representation of a value from an array.

What is the difficulty level of this exercise?



New Content: Composer: Dependency manager for PHP, R Programming