JSON Array In PHP

JSON Array in PHP

Hi readers this JSON tutorial is all about JSON Array. Here in this tutorial, we will explain the details about JSON Array which includes what JSON Array is, JSON Array with all other data types (like Strings, Numbers, and Boolean) and later on we will explain about JSON Array as an object and then the JSON Multidimensional Array also.

Let's begin the JSON tutorial on topic JSON Array in PHP!

JSON Array in PHP Syntax

[value1, value2, value3, ...]

Here we can see that []square bracket marks the beginning of JSON Array.

Each value in JSON Array must be separated by a comma(,).

  • JSON Array is just similar to Array in JavaScript which represent the ordered list of values.
  • JSON Array can hold multiple values with different data types (String, Number, Boolean, Object, and even null ) .

JSON Array in PHP Examples

Here is a list of a number of examples of JSON Array with different data types,

JSON Array of Strings

  1. "January""February""March""April""May""June""July" ]  

JSON Array of Numbers

  1. [ 13, 26, 39, 52, 65 ]  

JSON Array of Boolean

  1. [truefalsetrue ]  

JSON Array of Objects

  1. {  
  2.     "student": [{  
  3.         "name""Aakash",  
  4.         "email""[email protected]",  
  5.         "RollNo": 11  
  6.     }, {  
  7.         "name""Shreya jaiswal",  
  8.         "email""[email protected]",  
  9.         "RollNo": 09  
  10.     }, {  
  11.         "name""Shriram Prakash",  
  12.         "email""[email protected]",  
  13.         "RollNo": 12  
  14.     }] //end of array } //end of object  

Multidimensional JSON Array

Multidimensional Array is the same concept of Array of Arrays like any other programming language C, C++ etc. A multidimensional array is nothing but a JSON array which contains one or more arrays. Here is a simple example of the multidimensional array,

  1. [[ "abc","xyz","pqr" ],[ 23, 34, 45 ],["P""Q""R" ]]  
Note 

Multidimensional Array with one, two, three, four, or more levels deep is understandable by PHP but however, it will be hard to manage more than a three levels deep Multidimensional Array.

I hope you liked this topic JSON Array in PHP.

https://techieflair.com..Read More
Next Recommended Reading Retrieving JSON Data Using jQuery