冷水江市 盐城市 富顺县 安乡县 凌海市 双桥区 石家庄市 福鼎市 桃园市 竹北市 开鲁县 北碚区 华安县 沛县 崇文区 洱源县

强军战歌_二叉树结构 统计每一个叶子节点下的节点的数量

标签:特许经营 炸金花官方网站

类如下:

<?php
class getUserLeftRightNumber
{
    public $arr_all;
    public $arr_init;
    public $arr_leaf;
    public $arr_res;
    public function __counstruct()
    {
    
    }

    public function getUserNum()
    {
        // ini_set("memory_limit","6144M");
        // set_time_limit(0);

        // header("content-type:text/html;charset=utf-8"); 
        // define("DB_HOST","127.0.0.1"); 
        // define("DB_USER","root"); 
        // define("DB_PASS","root"); 
        // define("DB_NAME","test"); 
        // define("DB_PORT",3306); 
        // define("DB_CHAR","utf8"); 
        // define("APPNAME",""); 
        // $mysqli = new mysqli( DB_HOST, DB_USER, DB_PASS, DB_NAME);
        // $rst = $mysqli->query( "set names " . DB_CHAR );
        // $sql = "select * from ub_user_expand";
        // $result=$mysqli->query($sql);
        // $array=array(); 
        // while( $rows=$result->fetch_assoc() )
        // {
        //     $r["uid"] = $rows["uid"];
        //     $r["name"] = $rows["username"];
        //     $r["_referee"] = $rows["_referee"];
        //     $r["_left"] = $rows["_left"];
        //     $r["_right"] = $rows霸道校草宠溺爱_2018年最新新闻网_all[6]  = array("uid" => "10000006", "_referee" => "102002", "name" => "103004", "_left" => "10000013", "_right" => "10000014", "position" => 2 );
        $this->arr_all[7]  = array("uid" => "10000007", "_referee" => "103001", "name" => "104001", "_left" => "10000015", "_right" => "10000016", "position" => 1 );
        $this->arr_all[8]  = array("uid" => "10000008", "_referee" => "103001", "name" => "104002", "_left" => "10000017", "_right" => "10000018", "position" => 2 );
        $this->arr_all[9]  = array("uid" => "10000009", "_referee" => "103002", "name" => "104003", "_left" => "10000019", "_right" => "10000020", "position" => 1 );
        $this->arr_all[10] = array("uid" => "10000010", "_referee" => "103002", "name" => "104004", "_left" => "10000021", "_right" => "10000022", "position" => 2 );
        $this->arr_all[11] = array("uid" => "10000011", "_referee" => "103003", "name" => "104005", "_left" => "10000023", "_right" => "10000024", "position" => 1 );
        $this->arr_all[12] = array("uid" => "10000012", "_referee" => "103003", "name" => "104006", "_left" => "10000025", "_right" => "10000026", "position" => 2 );
        $this->arr_all[13] = array("uid" => "10000013", "_referee" => "103004", "name" => "104007", "_left" => "10000027", "_right" => "10000028", "position" => 1 );
        $this->arr_all[14] = array("uid" => "10000014", "_referee" => "103004", "name" => "104008", "_left" => "10000029", "_right" => "10000030", "position" => 2 );
        $this->arr_all[15] = array("uid" => "10000015", "_referee" => "104001", "name" => "105001", "_left" => "",  "_right" => "", "position" => 1 );
        $this->arr_all[16] = array("uid" => "10000016", "_referee" => "104001", "name" => "105002", "_left" => "",  "_right" => "", "position" => 2 );
        $this->arr_all[17] = array("uid" => "10000017", "_referee" => "104002", "name" => "105003", "_left" => "",  "_right" => "", "position" => 1 );
        $this->arr_all[18] = array("uid" => "10000018", "_refere雅漾_2018年最新新闻网   $this->arr_res[$res_key]["uname"] = $res_key;

            if ( $leaf["position"] == "left" ) 
            {
                $this->arr_res[$res_key]["numLeft"] = $count_a铃木_2018年最新新闻网ll;
                $count = $count_all;

                if ( isset( $this->arr_res[$res_key]["numRight"]) ) 
                {
                    $count = $this->arr_res[$res_key]["numLeft"] + $this->arr_res[$res_key]["numRight"];
                }
            }
            elseif ( $leaf["position"] == "right" ) 
            {
                $this->arr_res[$res_key]["numRight"] = $count_all;
                $count = $count_all;
                if ( isset( $this->arr_res[$res_key]["numLeft"]) ) 
               聊城_2018年最新新闻网 {
                    $count = $this->arr_res[$res_key]["numLeft"] + $this->arr_res[$res_key]["numRight"];
                }
            }
            else 
            {
                return false;
            }

            // 获取上级、然后递归
            $referee = isset($all[$leaf["_referee"]])&&!empty($leaf["_referee"]) ? $all[$leaf["_referee"]] : "";
            if ( !empty( $referee ) ) 
            {
                $this->getUserNumInit( $all, $referee, $count );
            }

        }
    }
}

使用

$obj = new getUserLeftRightNumber();
$obj->getUserNum();

当前文章:http://dgf-jiaqipian-com.kangresearch.cn/uvgxgx6/88ca8_153170.html

发布时间:2019-07-19 00:26:47

澳门银河送彩金雷军香港见李嘉诚 长和与小米达成合作  澳门银河娱乐yh163am.com  澳门银河娱乐yh163am.com  澳门银河娱乐yh163am.com  澳门银河娱乐yh163am.com  澳门银河送彩金  澳门银河yh99.com  澳门银河送彩金  银河国际手机网址2949  澳门银河真人yh163am.com