What is JSON?
JavaScript Object Notation (JSON) is a standard textual format for storing and transmitting data over a network based on JavaScript. Despite its origins in JavaScript, this format is considered language-independent; JSON can use with almost any programming language, including JavaScript, Java, C ++, C #, Go, PHP, Python, and many others.
How to encode a PHP array into a JSON string?
There are two types of arrays in PHP: regular and associative (an associative array uses a key-value structure to store data). The json_encode() function can convert both array types to a JSON data string. We convert an associative array to a JSON string in the example below.
How to convert a multidimensional associative PHP array to JSON?
The example shows how to convert a multidimensional associative array to JSON using the json_encode() function: