JSON
json_encode turns data into JSON and json_decode reads it. Pass true to decode to an array.
Example
$d = ["name" => "Ada", "tags" => ["a", "b"]];
$j = json_encode($d);
echo $j, "\n";
var_dump(json_decode($j, true)["name"]);Result
{"name":"Ada","tags":["a","b"]}
string(3) "Ada"Exercise
Array from JSON.
json_decode($j, )
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.