以下算法将用户添加到公司数组。我想为任何给定的公司添加用户总数。我是怎么做的
public function all_company_information($id = null){
$arrCompany = array();
$arrCompany['company']= array();
$arrData = 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;
}
}
}