PHP - Php Json_decode()
{ "data": [ { "name": "Social Media Manager", "category": "Local business", "id": "164691116879928" }, { "name": "Support! Muffin the fool (Oldham Chronicle FAKE)", "category": "Community", "id": "181377645219010" }, { "name": "Northplanet", "category": "Local business", "id": "132483460132622" }, { "name": "Social Media Manager", "category": "Application", "id": "102650199811234" }, { "name": "Top Ten Things To Remember Me By!", "category": "Application", "id": "375102030458" } ]}
how would i use $user = json_decode($json) to access the value of the first id like $user->id(0); but that dose'tn work! Similar TutorialsThis topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=350103.0 php5 I am using json_encode() to store an array of data as a string in a mysql data base. I then extract the sting from the data base and convert the back into an array using json_decode. This works great up until I have any line breaks in any of the data. When there is a line break, the json_decode() function chokes and returns nothing. I would really like to keep the line breaks. Has anyone come across this issue/have an suggestions/solutions? json_decode returns a stdClass Object. Is there any way where I can get instance of my class instead of the same? I mean If I json_decode the below string then it will provide me instance of stdClass and not instance of Person class {"name":"a"} How to achieve the same? Thanks in advance CSJakharia |