Answer the question
In order to leave comments, you need to log in
How to select the necessary elements from json?
Hello. Help solve the issue.
This json is returned:
How to select all elements (in php) lying in data->images->low_resolution->url.
Thanks for the help.
Answer the question
In order to leave comments, you need to log in
$array = json_decode($json, true);
$result = array();
foreach($array['data'] as $item) {
$result[] = $item['images']['low_resolution']['url'];
}
Use array_column()
$urls = array_column(array_column(array_column(array_column(json_decode($jsonString ,true), 'data'), 'images'), 'low_resolution'), 'url');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question