Tools, FAQ, Tutorials:
json_decode() - JSON Array to PHP Array
How to access elements from the PHP array returned from json_decode() on a JSON array?
✍: FYIcenter.com
By default, json_decode() will convert a JSON Array to a PHP array with 
integer indexes of 0, 1, 2, ... 
There are different ways to access elements in the output PHP array:
Here is a PHP example that shows you how to access elements from the array returned by json_decode():
<?php
# json_decode_array.php
# Copyright (c) FYIcenter.com 
   $json = '["a","b","x-y"]';
   print("\nInput: ".$json."\n");
# Decoded into an array
   $array = json_decode($json);
   print("\nOutput Array:\n");
   print("   Type: ".gettype($array)."\n");
   print("   Size: ".count($array)."\n");
   print("   [0]: ".$array[0]."\n");
   print("   [2]: ".$array[2]."\n");
# Dump the array
   print("\nOutput Array Dump:\n");
   var_dump($array);
?>
If you run the above PHP code through the PHP engine, you get the following output:
>\fyicenter\php\php.exe json_decode_array.php
Input: ["a","b","x-y"]
Output Array:
   Type: array
   Size: 3
   [0]: a
   [2]: x-y
Output Array Dump:
array(3) {
  [0]=>
  string(1) "a"
  [1]=>
  string(1) "b"
  [2]=>
  string(3) "x-y"
}
⇒ json_decode() - JSON Object to PHP Object
2021-08-04, ∼3507🔥, 1💬
Popular Posts:
How to login to the Developer Portal internally by you as the publisher? Normally, the Developer Por...
How to start Visual Studio Command Prompt? I have Visual Studio 2017 Community version with Visual C...
dev.FYIcenter.com is a Website for software developer looking for software development technologies,...
Where to find tutorials on RSS specifications? I want to learn it to describe my API services. Here ...
Where to get the detailed description of the JSON.stringify() Function in JavaScript? Here is the de...