zoukankan      html  css  js  c++  java
  • PHP无限极分类

    <?php
    /**
     * Created by PhpStorm.
     * User: Administrator
     * Date: 16-2-1
     * Time: 下午11:39
     */
    namespace HomeController;
    
    use ThinkController;
    
    class CateController extends Controller{
        public function index(){
            $arr = array(
                array(
                    'id' => 1,
                    'name' => 'PHP',
                    'pid' => 0,
                    'path' => '0'
                ),
                array(
                    'id' => 2,
                    'name' => 'JAVA',
                    'pid' => 0,
                    'path' => '0'
                ),
                array(
                    'id' =>3,
                    'name' => 'ThinkPHP',
                    'pid' => 1,
                    'path' => '0-1'
                ),
                array(
                    'id' =>4,
                    'name' => 'Spring',
                    'pid' => 2,
                    'path' => '0-2'
                ),
            );
            foreach($arr as &$arr2){
                $num = substr_count($arr2['path'],'-');
                if($arr2['pid'] > 0){
                    $pre = '|'.str_repeat('-',$num);
                }else{
                    $pre = '';
                }
                $arr2['tree'] = $pre.$arr2['name'];
            }
    
            foreach($arr as $arr3){
                $rows[] = $arr3['path'].'-'.$arr3['id'];
            }
            array_multisort($rows,$arr);//多数组排序
           // print_r($arr);
            $this->assign('arr',$arr);
            $this->display();
        }
    }
    ?>
  • 相关阅读:
    jquery---stop()
    标准设备的-media queries
    CSS3 Media Queries
    css---------selector
    sublime----(1)
    XAMPP、WAMP、appserv
    Express.js----路由
    nodejs----上传显示图片
    node.js-----处理POST请求
    DotNetOpenAuth使用笔记
  • 原文地址:https://www.cnblogs.com/finnlee/p/5176610.html
Copyright © 2011-2022 走看看