I am trying to get a count of active users and unactive users.
First i get all user data:
$userData = fetchAllUsers();
Then I write a foreach to get a total of the users who are active and the users who are unactive.
foreach ($userData as $key => $value) {
$active = $value['active'];
if($active == 1){
$activeUsers = count($active);
print_r($activeUsers);
} elseif($active == 0) {
$unactiveUsers = count($active);
print_r($unactiveUsers);
}
}
All this prints is 1111111. There are 5 users set to 1 (active) and 2 users set to 0 (unactive) in the database. So I am looking to add these up to be 5 active and 2 unactive.
I have triedcount and array_sum and array_count_values. Nothing seems to be doing what I need. Any help would be appreciate. Can someone guide me in the right direction?
(int) $variable