Skip to content
Advertisement

Get response variables from array

I am trying to output all the users I have created in my Marqeta API Sandbox environment. I’m making a GET request to /users through my custom marqetaAPI function that handles each request type.

Call to custom API function:

JavaScript

Custom function API Call with cURL:

JavaScript

Decoding response array with json_decode:

JavaScript

Here is the json decoded array:

JavaScript

I’m calling the response array nested ‘data’ key here. The result is 5 arrays (one for each user)

JavaScript

Say I wanted the first users keys and values I would do:

JavaScript

Now lets say i want to echo each users keys and values I would do something like:

JavaScript

with expected output:

JavaScript

Advertisement

Answer

If you only want to echo all arrays in variable depth, then this function is a solution:

JavaScript

Based on your comment above – echo only one key:

JavaScript

Or if you want to echo all the data:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement