Предыстория: Пытаюсь получить список комментаторов с большого количества постов.
Вопрос: Как можно очистить полученный массив от всего лишнего, чтобы на выходе получить только массив с всеми ["id"] (Только тот который лежит в ["profiles"] ?
Пытался при помощи циклов внутри циклов, но далеко не уехал, быстро запутался.
array(1) {
["response"]=>
array(4) {
["count"]=>
int(4)
["items"]=>
array(4) {
[0]=>
array(4) {
["id"]=>
int(4001)
["from_id"]=>
int(359842340)
["date"]=>
int(1530078966)
["text"]=>
string(10) "Текст коментария"
}
[1]=>
array(4) {
["id"]=>
int(4002)
["from_id"]=>
int(359842340)
["date"]=>
int(1530078979)
["text"]=>
string(45) "Текст коментария"
}
[2]=>
array(4) {
["id"]=>
int(4003)
["from_id"]=>
int(359842340)
["date"]=>
int(1530079019)
["text"]=>
string(78) "Текст коментария"
}
[3]=>
array(4) {
["id"]=>
int(4015)
["from_id"]=>
int(165517974)
["date"]=>
int(1530346405)
["text"]=>
string(150) "Текст коментария"
}
}
["profiles"]=>
array(2) {
[0]=>
array(8) {
["id"]=>
int(165517974)
["first_name"]=>
string(14) "Дмитрий"
["last_name"]=>
string(29) "Новожилов-Шухов"
["sex"]=>
int(2)
["screen_name"]=>
string(10) "grim_jager"
["photo_50"]=>
string(69) "https://pp.userapi.com/c844720/v844720372/8decc/RKhvEtIoWaQ.jpg?ava=1"
["photo_100"]=>
string(69) "https://pp.userapi.com/c844720/v844720372/8decb/Sy_iO9EiqbY.jpg?ava=1"
["online"]=>
int(0)
}
[1]=>
array(8) {
["id"]=>
int(359842340)
["first_name"]=>
string(14) "Радимир"
["last_name"]=>
string(14) "Павелич"
["sex"]=>
int(2)
["screen_name"]=>
string(16) "radimir_pavelich"
["photo_50"]=>
string(69) "https://pp.userapi.com/c845221/v845221606/4e459/19THGOMLHJ8.jpg?ava=1"
["photo_100"]=>
string(69) "https://pp.userapi.com/c845221/v845221606/4e458/UiUrY-ZOGYs.jpg?ava=1"
["online"]=>
int(0)
}
}
["groups"]=>
array(0) {
}
}
}
Вот код цикла которым получаю эти массивы комментариев:
for ($i=0; $i<=count($arrays); $i++) {
$query = file_get_contents("https://api.vk.com/method/wall.getComments?owner_id=-".$group_id."&extended=1&post_id=".$ids[$i]."&need_likes=0&count=100&extended=1&v=5.80&access_token=".$access_token);
//Вбиваем массивы с комментариями в единый массив
$result = json_decode ($query,true);
$pIds = array_column($result['response']['profiles'], 'id');
vardump($pIds);
//usleep(450000);
};