I have this JSON Array in PHP which I receive from an Android request and I want to decode it so that I can get every value of each object in a loop and send them to a mysql database.
So in the example beneath, there's a class with two objects including properties FirstName and LastName. I would like to pars this json so that I can use them in a PDO function which inserts these rows in a mysql database.
[
{ "firstName":"John" , "lastName":"Doe" },
{ "firstName":"Anna" , "lastName":"Smith" },
{ "firstName":"Peter" , "lastName":"Jones" }
]
How do I accomplish this. After a lot of trial and error it still won't work. Thanks in advance!
Edit: json_decode worked after all. JSON syntax issue was the problem.