4
PHP foreach循环键值
我正在运行此数据库调用以获取多维数组,我试图获取每个数组的键,但是当我尝试将其显示为空白或数组时。 $root_array = array(); $sites = $this->sites($member_id); foreach ($sites as $site){ $records = $this->db->select('p.name as place_name, p.id as place_id,p.active as place_status') ->from('places p') ->join('members_permissions pm','pm.sites_id = p.sites_id and pm.members_id ='.$member_id) ->where('p.active', 0) ->get(); $places = $records->result_array(); $places['name'] = $site['name']; foreach($places as $place){ $root_array[$site['name']][] = $place; } } return $root_array; 这是我的php循环遍历: …