PHP基础实例 | 无级分类作者王明昌发布时间2018-10-16最后更新2018-10-16复制$value) { if($value['father_id'] == $id) { $value['depth'] = $depth; $tree[] = $value; subTree($arr, $value['id'], $depth+1); //tree($arr, $value['id'],$depth+1); } } return $tree; } function fatherTree($arr,$id) { static $list = array(); foreach($arr as $v) { if($v['id'] == $id) { fatherTree($arr,$v['father_id']); $list[] = $v; } } return $list; } $arr = [ ['id'=>1,'name'=>'news','father_id'=>0], ['id'=>2,'name'=>'article','father_id'=>0], ['id'=>3,'name'=>'local news','father_id'=>1], ['id'=>4,'name'=>'good article','father_id'=>2], ['id'=>5,'name'=>'bad article','father_id'=>2], ['id'=>6,'name'=>'sea','father_id'=>4], ]; $tree = subTree($arr); foreach($tree as $v){ echo str_repeat('----',$v['depth']).$v['name'].$v['depth'].''; } $list = fatherTree($arr,6); foreach ($list as $key => $value) { echo $value['name'].'>>'; }
2017-11-18PHP函数-数学函数abs 格式 描述 输入 输出 abs() 绝对值 整形/浮点型/字符串/进制数 与输入相对应 实例: $a = -12;//12 $a = -112.02;//11.02 $a = "-123.2"
2018-05-27获取上一级页面的url参考地址:http://www.qdxw.net/xwhtml/384.html 实战代码 从4.php 点击进入5.php 1.上一页地址: http://localhost/box/4.php 2
2017-11-19PHP函数why 提高开发效率 提高代码的重用性 有利于代码的维护 格式 function funName(形参,形参) { 代码块; return; } 函数名格式 函数名不区分大小写 函数名不能以数字开头,
2017-12-16转载 | PHP常用函数总结(180多个)数学函数 1.abs(): 求绝对值 $abs = abs(-4.2); //4.2 数字绝对值数字 2.ceil(): 进一法取整 echo ceil(9.999); // 10 浮点数进一取整 3
2017-11-19PHP基础语法php格式4种形式 1.1 标准式 1.2 短风格 1.3. asp风格 1.4 脚本风格 注: 1.2/1.3需要修改php.in文件 各改为short_open_tag = On asp_tags