Using var_dump from an API call give me the output like this
How to put them into an array? thanks
You can use json_encode
to convert it to a json. After which you can use json_decode
with the second parameter set to true
which will return an array instead of an StdObject
.
If the api you're calling simply returns a json itself then you can go ahead and use json_decode
directly with the second argument set to true
to yield the same result.
There are other ways, but this is the simplest.
You can check out other questions, like this one or this one.