Home > php教程 > php手册 > 解决PHP树型类(Tree.class.php)未节点不对齐问题

解决PHP树型类(Tree.class.php)未节点不对齐问题

WBOY
Release: 2016-06-06 19:39:41
Original
917 people have browsed it

做过PHP的同学可能都用过这个类,非常好用,但是有个小问题,在显示最后一个节点的时候会出现不对齐问题。 原代码我就不贴了,详见: http://www.oschina.net/code/snippet_99943_1452 http://www.oschina.net/code/snippet_99943_2521 修改的地方有两个,见

做过PHP的同学可能都用过这个类,非常好用,但是有个小问题,在显示最后一个节点的时候会出现不对齐问题。

原代码我就不贴了,详见:
http://www.oschina.net/code/snippet_99943_1452
http://www.oschina.net/code/snippet_99943_2521

修改的地方有两个,见以下代码片段:

//1:给$icon数组增加第4个元素,一个空格

var $icon = array('│', '├', ' └', ' ');

//2在类似get_tree/get_tree_multi的函数中增加一行代码 $k = $adds ? $this->icon[3] : '';

if ($number == $total) {
    $j .= $this->icon[2];
    $k = $adds ? $this->icon[3] : '';
}
Copy after login

解决PHP树型类(Tree.class.php)未节点不对齐问题

解决PHP树型类(Tree.class.php)未节点不对齐问题

Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template