Site Loader
Get a Quote
JSON Array in PHP
JSON Array in PHP

JSON Tutorial:  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 is JSON Array, JSON Array with all other data types (like Strings, Numbers, and Boolean) and later on we 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:
[ "January", "February", "March", "April", "May", "June", "July" ]
JSON Array of Numbers:
[ 13, 26, 39, 52, 65 ]
JSON Array of Boolean:
[true, false, true ]
JSON Array of  Objects:
"student" : [
{ "name" :"Aakash", "email" : "", "RollNo": 11 },
{ "name" :"Shreya jaiswal", "email" : "", "RollNo": 09 },
{ "name" :"Shriram Prakash", "email" : "", "RollNo": 12 }
]              //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:

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

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 three levels deep Multidimensional Array.

I hope you would like this topic JSON Array in PHP

Post Author: TechieFlair

Leave a Reply

Your email address will not be published.