The content introduced in this article is about the unlimited distribution of PHP members. It has a certain reference value. Now I share it with everyone. Friends in need can refer to it.
Premise: Member table structure There are user userid and recommender tjuid (recommender tjuid is the userid who recommended the member)
$where = "`userid` > 1"; $ulist = $db->select($where,'userid,tjuid,username,nickname,mobile','','userid asc'); //将$ulist数组键名重置为该数组元素的userid值 foreach($ulist as $val){ $items[$val['userid']] = $val; } //利用变量引用实现无限级分类 foreach ($items as $item){ $items[$item['tjuid']]['son'][$item['userid']] = &$items[$item['userid']]; } print_r($items[0]['son']);
The above is the detailed content of Unlimited distribution for PHP members. For more information, please follow other related articles on the PHP Chinese website!