首页 > 开发 > PHP > 正文

使用PHP数组实现无限分类,不使用数据库,不使用递归.

2024-05-04 22:14:16
字体:
来源:转载
供稿:网友
代码如下:
<?php

class cat
{
    public $data;

    public function __construct() 
    {
        @include "data.php";
        $this->data = $class;
    }


    public function CreateSortLevel($fatherlevel)
    {
        if(empty($fatherlevel))
        {
            if(is_array($this->data))
            {
                $fast_level = array();
                foreach($this->data as $value)
                {
                    if(strlen($value["sortlevel"]) == 3)
                    {
                        $fast_level[] = $value["sortlevel"];
                    }
                }
                $max_fast_level = max($fast_level);
                unset($fast_level);
                $sub   = ceil($max_fast_level) + 1;
                switch(strlen($sub))
                {
                    case 1:
                        return "00{$sub}";
                        break;
                    case 2:
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表