[0] => Array
(
[id] => 6
[name] => Digitally Imported Psy Goatrance
[country] => GB
[image] => Array
(
[url] => https://img.dirble.com/station/6/original.png
[thumb] => Array
(
[url] => https://img.dirble.com/station/6/thumb_original.png
)
)
[slug] => digitally-imported-psy-goatrance
[website] => http://www.di.fm/
[twitter] =>
[facebook] =>
[total_listeners] => 0
[categories] => Array
(
[0] => Array
(
[id] => 1
[title] => Trance
[description] => stations that plays commercial and other things in trance-music genre.
[slug] => trance
[ancestry] => 14
)
)
[streams] => Array
(
[0] => Array
(
[stream] => http://pub1.di.fm:80/di_goapsy
[bitrate] => 48000
[content_type] => audio/mpeg
[status] => 1
[listeners] => 0
)
)
[created_at] => 2012-01-15T04:03:34+01:00
[updated_at] => 2016-04-26T19:45:54+02:00
)
[1] => Array
(
[id] => 7
[name] => Powerfmse
[country] => SE
[image] => Array
(
[url] =>
[thumb] => Array
(
[url] =>
)
)
[slug] => powerfmse
[website] => http://powerfm.se
[twitter] =>
[facebook] =>
[total_listeners] => 0
[categories] => Array
(
[0] => Array
(
[id] => 3
[title] => Dance
[description] => dance music, the new from 80's and 90's, like bubblegum and more.
[slug] => dance
[ancestry] => 14
)
[1] => Array
(
[id] => 14
[title] => Electronic
[description] => all computeriz made.
[slug] => electronic
[ancestry] =>
)
[2] => Array
(
[id] => 1
[title] => Trance
[description] => stations that plays commercial and other things in trance-music genre.
[slug] => trance
[ancestry] => 14
)
)
[streams] => Array
(
[0] => Array
(
[stream] => http://media.powerfm.se:80/high
[bitrate] => 160
[content_type] => ?
[status] => 1
[listeners] => 0
)
[1] => Array
(
[stream] => fffff
[bitrate] => 0
[content_type] => ?
[status] => 0
[listeners] => 0
)
)
[created_at] => 2012-01-15T05:53:31+01:00
[updated_at] => 2015-04-11T14:10:44+02:00
)
Мне нужно получить значения [description] из категорий и значения [stream] из потоков. Я показал только массив [0] до [1], их больше 20.
Я использую циклы for для получения всех данных.
<body>
<?php
$json_string = 'http://api.dirble.com/v2/stations?
token=123';
$jsondata = file_get_contents($json_string);
$obj = json_decode($jsondata,true);
?>
<p id = "demo"></p>
<script>
var i, j, x = "";
for (i in obj.categories) {
x += "<h2>" + obj.categories[i].description + "</h2>";
}
document.getElementById("demo").innerHTML = x;
</script>
</body>
Ребята, вы можете мне помочь? Я также могу попытаться отобразить это использование для каждого в php, пожалуйста, помогите? Спасибо.



![Безумие обратных вызовов в javascript [JS]](https://i.imgur.com/WsjO6zJb.png)


Вы должны сделать что-то вроде этого,
foreach(YOUR_MAIN_ARRAY as $value) {
foreach($value["categories"] as $tmpValue) {
foreach($tmpValue as $description){
echo $description["description"];
}
}
foreach($value["streams"] as $tmpValue) {
foreach($tmpValue as $stream){
echo $stream["stream"];
}
}
}
Он содержит синтаксические ошибки, которые я не тестировал, но логика понятна.
Получаю ошибку: Предупреждение: недопустимое смещение строки "описание" в C: \ xampp \ htdocs \ API \ inde.php в строке 21