Q:

Passing Array count to a variable

I think I'm close with my code but I am trying to get the count() from the array provided... total users and OS
        $users = array();
        if ($results = $dbh->runQuery($sql)) {

foreach ($results as $key=>$row){
        $users[$row['user_id']][] = array('user_id'=>$row['user_id'],
        'email' => $row['email'],
        'last_login' => $row['last_login'],
        'fname' => $row['fname'],
        'lname' => $row['lname'], 
        'role_id' => $row['role_id'],
        'role_name' => $row['role_name'],
        'os_d_token' => $row['os'],
        'roid_d_token' => $row['roid'],
        'p_name' => $row['p_name']);
            }
        }

Get total count of users
    $user_cnt = count($row['user_id']);

Get total count of users with OS
    $total_os = '';
    if($row['os'] != null || '-1') {

        $total_os = count($row['os']);

    }

A:

count does not retain a counter for you.  It immediately returns the number of items in an array.  Since you're already looping, set counter variables:
$total = 0;
$total_os = 0;
foreach ($results as $key=>$row) {
    $total++;
    if ($row['os'] != null || $row['os'] != '-1') {
        $total_os++;
    }
    ...
}

