0

Using var_dump from an API call give me the output like this

enter image description here

How to put them into an array? thanks

2
  • 2
    Presumably this is the result of json_decode($api_return_data)? If so, just change the call to json_decode($api_return_data, true) and you will get an associative array instead of an object. Commented Nov 19, 2018 at 6:24
  • Possible duplicate of Convert stdClass object to array in PHP Commented Nov 19, 2018 at 6:35

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.