PHP - JSON

JavaScript Object Notation (JSON) is a lightweight data-interchange format inspired by the object literals of JavaScript. JSON values can consist of

Objects: collections of name-value pairs

Arrays: ordered lists of values

Strings in double quotes

Numbers

True, false, or null

JSON and PHP

JSON encode/decode functions have been available in PHP since version 5.2. JavaScript's JSON stringify/parse methods are supported by all current browsers.JSON libraries and/or built-in support are provided for many other programming languages as well.

When passing data from PHP to JavaScript, the PHP json_encode function is used to return a string containing the JSON equivalent of the value passed to it. You can then use the JavaScript JSON.parse method to safely handle the data and make it available in a form usable by JavaScript.