JSON_DECODE - get values from multidimensional array stdClass

How can I get the specific value from multidimensional array with stdClass object using json_decode ? For example, when I use $array['users'][16] in regular array, I will get the value for user with ID 16. How can I do this in case of JSON ?
20 Jun 2021 at 12:10 PM
0pnshow more
LarsLars
Hi,

You can get the values from stdClass Object multidimensional array in a similar way, than in case of standard array. What you need to do, is include true parameter into json_decode function.

For example:

$json_array = '{"users":{"10":"Abc", "16":"Abcde"}}';

$array = json_decode($json_array, true);

echo $array['users'][16];

23 Jun 2021 at 10:25 AM
0pnshow more
TimTim
Share on FacebookShare on TwitterShare on LinkedInSend email
Follow us on Facebook & Twitter
2021 AnswerTabsTermsContact us