Here I have such an object in which there can be up to 10 Vkontakte users. Users have ID, first name, last name, photo.

It is necessary to bring all this to the loop. Tell me how it is done.

Array ([0] => stdClass Object ([id] => 288988637 [first_name] => Alexander [last_name] => Diamonds [photo_50] => http://cs630928.vk.me/v630928637/26da4/wGMdOYhIh7o.jpg ) [1] => stdClass Object ([id] => 10404485 [first_name] => Alexander [last_name] => Ivanov [photo_50] => http://cs631627.vk.me/v631627485/27bc5/xZXl4GBVcsQ.jpg ) )

    1 answer 1

    foreach($array as $v) { echo $val->id; echo $val->first_name; .... } 

    In general, if json_decode pass true second argument to json_decode , you will get an array, not an object.

    • Just leave it here: an array is usually transmitted with a name, for example {"sessions":[{"client_id":19733627,"addr":"172.16.96.141","u‌​ptime":730},{"client‌​_id":37268742,"addr"‌​:"172.16.112.95","up‌​time":5}]} to $result = json_decode($array); foreach($result->sessions as $res) echo $res->addr; over such an array, do so $result = json_decode($array); foreach($result->sessions as $res) echo $res->addr; $result = json_decode($array); foreach($result->sessions as $res) echo $res->addr; - ke1evra