add total to the array

shawnssj

New Member
the following algorithm add users to a company array. I want to add a total of user for any given company. Howd I go about doing that\[code\]public function all_company_information($id = null){ $arrCompany = array(); $arrCompany['company']= array(); $arrData = http://stackoverflow.com/questions/10540686/array(); $this->autoRender = false; $this->loadModel("User"); $users = $this->User->find('all'); foreach($users as $k => $user){ if(!in_array($user['User']['company_id'], $arrCompany['company'])){ $arrCompany['company'][$user['User']['company_id']][] = $user; }else{ $arrCompany['company'][$user['User']['company_id']][] = $user; } } }\[/code\]
 
Back
Top