Home >Backend Development >PHP Tutorial >Unlimited distribution for PHP members

Unlimited distribution for PHP members

不言
不言Original
2018-04-20 10:22:479138browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn