I currently have the following array:
Array(
[0] => Array
(
[user] => Name 1
[group] => 1
)
[1] => Array
(
[user] => Name 2
[group] => 1
)
[2] => Array
(
[user] => Name 3
[group] => 2
)
[3] => Array
(
[user] => Name 4
[group] => 2
)
[4] => Array
(
[user] => Name 5
[group] => 3
)
)
I am attempting to create a new array with the various group
values as the key, then count how many are in each group to give the following:
Array
(
[1] => 2
[2] => 2
[3] => 1
)
I have attempted to use the following, however I get undefined index warnings:
$newArr = array();
foreach ($details['user_groups'] as $key => $value) {
$newArr[$value['user_groups']]++;
}
(I did check SO for other answers, however couldn't find one attempting to do the same)