V
V
Vimake2014-01-01 18:49:50
PHP
Vimake, 2014-01-01 18:49:50

How to get multiple json?

There is this json:
{
"mac":{
"users":[{"id":1,"name":"user_Slon"},{"id":2,"name":"skypidar"},{" id":3,"name":"akakii"},{"id":4,"name":"slon"}]
}
}
How to display all name?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Belov, 2014-01-01
@Vimake

Let this object be in myobj.

for (var element in myobj.mac.users) {
    console.log(myobj.mac.users[element].name);
}

foreach ($myobj['mac']['users'] as $element) {
    echo $element['name'];
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question