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
- [ "January", "February", "March", "April", "May", "June", "July" ]
JSON Array of Numbers
JSON Array of Boolean
JSON Array of Objects
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" ]]
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