dimanche 30 septembre 2018

How to fetch an Array from MySQL with PHP

In my database I have POSTed following JSON with REST API:

{
    "author": "Someone",
    "hero_name": "Iron Man",
    "hero_desc": ["Iron", "Man"],
}

Now in myPhpAdmin Table, the entry says only Array for the hero_desc.

I cannot figure out how to get the actual items in that array.. for example to fetch Iron from hero_desc.

Here is how it gets returned with GET request:

{
    "id": "11",
    "user_id": "1",
    "author": "Someone",
    "hero_name": "Iron Man",
    "hero_desc": "Array",
}

I am quite new to PHP so I am worried that I would need to mess up my whole app architecture to get this to work. I though PHP can handle fetching arrays by default if it sees it's an JSON Array.




Aucun commentaire:

Enregistrer un commentaire