I have a Query string

{ "id": "105201322211272730088", "name": "Rayidi Radha Krishna", "given_name": "Rayidi", "family_name": "Radha Krishna", "link": "https://plus.google.com/105201322211272730088", "picture": "https://lh3.googleusercontent.com/-UTEdowBnUUE/AAAAAAAAAAI/AAAAAAAABd0/FrCv9VX1Pp4/photo.jpg", "gender": "male", "birthday": "0000-09-23", "locale": "en" }

I want to convert this Query string to an array. thanks in advance.

This looks like JSON, try json_decode.

commented: Your post impressing me since i was joined in Daniweb. Thank you +1

Dear Pritaes, thanks for the help. I realised that an JSON string.
I tried

$jsn = var_dump(json_decode($xmlresponse));

Response:

object(stdClass)#2 (9) { ["id"]=> string(21) "105201322211272730088" ["name"]=> string(20) "Rayidi Radha Krishna" ["given_name"]=> string(6) "Rayidi" ["family_name"]=> string(13) "Radha Krishna" ["link"]=> string(45) "https://plus.google.com/105201322211272730088" ["picture"]=> string(92) "https://lh3.googleusercontent.com/-UTEdowBnUUE/AAAAAAAAAAI/AAAAAAAABd0/FrCv9VX1Pp4/photo.jpg" ["gender"]=> string(4) "male" ["birthday"]=> string(10) "0000-09-23" ["locale"]=> string(2) "en" }

Now i'm not able to retreve the array. Basically i'm not aware of Arrays. I want to display

Firstname : Radha Krishna, Surname : Rayidi, Gender : male, Birthday : 0000-09-23

Please help me.

$values = json_decode($xmlresponse);
echo $values['name'];
echo $values['given_name'];
echo $values['birthday'];

Fatal error: Cannot use object of type stdClass as array in /home/student/public_html/api/validate.php on line 102

The error comming while compiling.

Show your code.

/home/student/public_html/api/validate.php on line 102

And which one is line 102?

commented: echo $values['name']; is in line 102 +0

The original string is for a JSON encoded object not an array.

To use the output as an array, you would need to convert it to an array. Notice the second argument for json_decode is true.

var_dump(json_decode($json, true));
commented: Thnx .. Its worked +1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.