2

i have tried many ways to split the string though am not that good in this programing language my string looks like this

{"success":true," URL ":"WWW.face-book.com", "rank":9, "details":null}

how do i separate my strings in such a way that the output looks like-

URL: WWW.face-book.com
rank: 9
Barmar
  • 741,623
  • 53
  • 500
  • 612
Ruchika Singh
  • 41
  • 1
  • 2

1 Answers1

1

You use json_decode($yourJsonStringHere); and youll get an Object of the class "stdClass" with public properties for all your keys.

So you can basically do the following:

$jsonObj=json_decode($jsonString);
echo $jsonObj->URL;
echo $jsonObj->rank;
echo $jsonObj->success;
echo $jsonObj->details;

See http://php.net/manual/en/function.json-decode.php for more info on the function itself.

Fabian S.
  • 2,441
  • 2
  • 24
  • 34