{"id":6,"first_name":"Николай","last_name":"Дуров","is_closed":false,"can_access_closed":true,"sex":2},
{"id":11,"first_name":"Михаил","last_name":"Петров","is_closed":false,"can_access_closed":true,"sex":2},
{"id":34,"first_name":"Татьяна","last_name":"Плуталова","is_closed":false,"can_access_closed":true,"sex":1},
"sex"
). 2 - мужская стать, 1 - женская. sex: 2
в массиве и к-во "sex": 1
?$sex_query = json_decode(file_get_contents('https://api.vk.com/method/groups.getMembers?group_id='.$id_group.'&fields=sex&access_token='.$token.'&v='.$v), true);
foreach ($sex_query['response']['items'] as $data_sex) {
$array = array($sex_query['sex']);
$result = array_count_values($array);
echo $result[1];
$query_members = file_get_contents('https://api.vk.com/method/groups.getMembers?group_id='.$id_group.'&fields=sex&access_token='.$token.'&v='.$v);
$sex_query = json_decode($query_members, true);
foreach ($sex_query['response']['items'] as $data_sex) {
$array[] = $data_sex['sex'];
}
$result = array_count_values($array);
foreach ($result_groups['response'] as $item) {
$id_group = $item['id'];
$member_count = $item['members_count'];
$result_member = number_format($member_count, '0', '', ' ');
$wall = json_decode(file_get_contents('https://api.vk.com/method/wall.get?owner_id=-'.$id_group.'&count=5&fields=id,text,date,views&access_token='.$token.'&v='.$v), true);
$wall_get = $wall['response']['items'][1];
$views = $wall_get['views']['count'];
$wall_get_1 = $wall['response']['items'][2];
$views_1 = $wall_get_1['views']['count'];
$wall_get_2 = $wall['response']['items'][3];
$views_2 = $wall_get_2['views']['count'];
// Определение стати
$query_members = file_get_contents('https://api.vk.com/method/groups.getMembers?group_id='.$id_group.'&fields=sex&access_token='.$token.'&v='.$v);
$sex_query = json_decode($query_members, true);
foreach ($sex_query['response']['items'] as $data_sex) {
$array[] = $data_sex['sex'];
}
$result = array_count_values($array);
echo $result[1].'<br>';
echo $result[2];
$result_view = round(($views + $views_1 + $views_2)/3);
echo ' <table class="table" width="100%">
<tr class="tr">
<th class="td">
<img class="photo_200_li" src="'.$item['photo_200'].'"><p class="li_name_groups">'.$item['name'] .'</p></th>
<th><p class="temat">'.$item['activity'].'</p></th>
<th><p class="temat">'.$result_member.'</p></th>
<th><p class="temat">'.$result_view.'</p></th>
<th>Пол</th>
<th>Прирост</th>
</tr>
</table>
';
}
<?php
// Вызов айди сообществ, инфу о которых надо получить
require_once('controller/groupsController.php');
Тут я получаю станлартную инфу о сообществах
$group_get = file_get_contents('https://api.vk.com/method/groups.getById?group_ids='.$result_popular_groups.'&fields=id,name,photo_200,members_count,activity&access_token='.$token.'&v='.$v);
foreach ($result_groups['response'] as $item) {
// Получаю айди группы
$id_group = $item['id'];
// Это надо для вывода к-ва просмотров записи в среднем, не обращайте внимания
$wall = json_decode(file_get_contents('https://api.vk.com/method/wall.get?owner_id=-'.$id_group.'&count=5&fields=id,text,date,views&access_token='.$token.'&v='.$v), true);
// Определение стати
$query_members = file_get_contents('https://api.vk.com/method/groups.getMembers?group_id='.$id_group.'&fields=sex&access_token='.$token.'&v='.$v);
$sex_query = json_decode($query_members, true);
foreach ($sex_query['response']['items'] as $data_sex) {
$array[] = $data_sex['sex'];
}
$result = array_count_values($array);
echo $result[1].'<br>';
echo $result[2];
echo $item['photo_200'];
}
?>
$result = array_count_values($array);
//тут удалим переменную...
unset($array);
//либо просто преинициализировать переменную array
$array = array();