recently i used some JSON data in JQuery. now i want the same thing in PHP.
For Example:
MySQL query returns data like
$result='{"username":"john","age":"18", "birthdate":"19880221"}';
but when i echo this data in PHP, like:
echo $result.username;
echo $result.age;
it shows output:
{"username":"john","age":"18", "birthdate":"19880221"}.username
{"username":"john","age":"18", "birthdate":"19880221"}.age
but i want output this:
John
18
PHP is not Javascript, the
.operator is for string concatenation and PHP has no native support for JSON syntax. You need to convert the JSON formatted data into an array and use array syntax: