Good afternoon I would like to know how I can pass data obtained from api key web, which are serialized. I want to pass them to html table. It comes like this:
[{"Plate":"XC9888","Year":"2004"}]1
Good afternoon I would like to know how I can pass data obtained from api key web, which are serialized. I want to pass them to html table. It comes like this:
[{"Plate":"XC9888","Year":"2004"}]1
Use json_decode (). When you get the content of the document it comes in string format. With
json_decode($json_string);
Transforms it into an array. For more information, see the api because it offers many extra options.
Edit: Keep in mind, that the json does not end in "," because it gave me a lot of headaches in his day.
Ex:
{"Plate":"XC9888","Year":"2004"} // Así valdría
{"Plate":"XC9888","Year":"2004",} // Así daría error (o no saldría nada)
There is a parameter if the API is in ASP.NET to remove those brackets and show it as PHP can read it and convert it into an array, check the JSON formation parameter of the API.
Now in PHP you can convert it to an array with json_decode ($ json_string);
And then do a foreach to print the rows of the table.