Answer the question
In order to leave comments, you need to log in
Objects. How to get object key and nested object key?
Hello, I have little experience in working with objects and arrays, but I hope I will explain the essence clearly ...
I receive a callback from the server that looks like this:
We need only the keys of the parent and child object. And is it possible to give names to the keys of the object and the child object?
For example, what would look like this:
{device_id:11841221:{ user_id: 11853024, user_id: 1183211, user_id: 12312123}}?
Answer the question
In order to leave comments, you need to log in
$json = json_decode($response, true);
the second argument of the method will immediately return you a dictionary instead of an object, with keys instead of object field names. You can loop through it as you like and do whatever you want with it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question