http://www.thinkphp.cn/code/4463.html
<?php
public function GetTeamMember($members, $mid) {
$teams=array();//最终结果
$teams[$mid] = '';
foreach ($members as $k=>$v) {
if ( isset($teams[$v['active_uid']]) ) {
$teams[$v['uid'] ] = '';
unset($members[$k]);
} else {
unset($members[$k]);
}
}
//因为获取的是第一个会员下级,所以删除第一个会员
unset($teams[$mid]);
return array_keys($teams);
}
tp5的写法
public function getAllChildcateIds($categoryID)
{
//初始化ID数组
$array[] = $categoryID;
do
{
$ids = '';
$mp['higher_id'] = array('in',$categoryID);
$cate = Db::name('user_info')->where($mp)->select()->toArray();
//循环二级分类
foreach ($cate as $k=>$v)
{
// unset($cate[0]);
$array[] = $v['id'];
unset($array[0]);
$ids .= ',' . $v['id'];
}
$ids = substr($ids, 1, strlen($ids));
$categoryID = $ids;
}
while (!empty($cate));
$ids = implode(',', $array);
// return $ids; // 返回字符串
return $array;//返回数组
}