How this json encode example works
Associative arrays become JSON objects and lists become JSON arrays. JSON_PRETTY_PRINT adds indentation. See json_encode() for flags and for why it can return false.
Convert a PHP array to JSON with json_encode(). Edit the code below and press Run to execute it with real PHP in your browser.
{"name":"John","age":30,"skills":["PHP","JavaScript","Python"]}
{
"name": "John",
"age": 30,
"skills": [
"PHP",
"JavaScript",
"Python"
]
}
Associative arrays become JSON objects and lists become JSON arrays. JSON_PRETTY_PRINT adds indentation. See json_encode() for flags and for why it can return false.