K
K
karach02017-02-17 20:24:01
PHP
karach0, 2017-02-17 20:24:01

How to properly get data from the converted JSON array into an object?

Good evening, I am writing authorization for the site through VKontakte. VK provides data in the form of a JSON array, but does it in such a way that attempts to get data from it using methods known to me are impossible.

object(stdClass)#4 (1) { ["response"]=> array(1) { [0]=> object(stdClass)#5 (4) { ["id"]=> int(1) ["first_name"]=> string(18) "Павел" ["last_name"]=> string(14) "Дуров" ["hidden"]=> int(0) } } }

As we can see, there is a zero there, which imposes an error on the $obj->response->0->id request. Actually, how to get the first_name and last_name lines from there ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Yarkov, 2017-02-17
@karach0

How did it happen?
$obj->response[0]->id

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question