Answer the question
In order to leave comments, you need to log in
How to parse the code?
How to parse this code?
{"response":[{"id":55xxxxx,"first_name":"Сергей","last_name":"Сергеев","sex":2,"photo_max_orig":"url"}]}
$user = json_decode($info, true);
$photo = $user['photo_max_orig'];
Notice: Undefined index: photo_max_orig
Answer the question
In order to leave comments, you need to log in
Try $photo = $user->photo_max_orig
And in order to avoid such questions, you can see what's inside $user like this:
var_dump($user) or print_r($user) + it is desirable to wrap it in a tag for convenience - it will make the output more readable.
$user = json_decode($info, true);
$photo = $user->{'photo_max_orig'};
Print_r:
Array ( [response] => Array ( [0] => Array ( [id] => 55xxxx [first_name] => Сергей [last_name] => Сергеев [sex] => 2 [screen_name] => id55xxxx [bdate] => 16.3.1994 [photo_max_orig] => url ) ) )
Just in case, comrade @Rickon above meant the pre tag. Something like:
<pre><?=var_dump($user)?></pre>
<pre><?=print_r($user)?></pre>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question