• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP printTree函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中printTree函数的典型用法代码示例。如果您正苦于以下问题:PHP printTree函数的具体用法?PHP printTree怎么用?PHP printTree使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了printTree函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: printTree

function printTree($level = 1)
{
    // Открываем каталог и выходим в случае ошибки.
    $d = @opendir(".");
    if (!$d) {
        return;
    }
    while (($e = readdir($d)) !== false) {
        // Игнорируем элементы .. и .
        if ($e == '.' || $e == '..') {
            continue;
        }
        // Нам нужны только подкаталоги.
        if (!@is_dir($e)) {
            continue;
        }
        // Печатаем пробелы, чтобы сместить вывод.
        for ($i = 0; $i < $level; $i++) {
            echo "  ";
        }
        // Выводим текущий элемент.
        echo "{$e}\n";
        // Входим в текущий подкаталог и печатаем его
        if (!chdir($e)) {
            continue;
        }
        printTree($level + 1);
        // Возвращаемся назад
        chdir("..");
        // Отправляем данные в браузер, чтобы избежать видимости зависания
        // для больших распечаток.
        flush();
    }
    closedir($d);
}
开发者ID:igorsimdyanov,项目名称:php7,代码行数:35,代码来源:tree.php


示例2: HandleViewSite

function HandleViewSite()
{
    define("CMD_SEL_ITEMSCOUNT", <<<SQL
\t\tSELECT count(*) FROM items
\t\t\tWHERE category_id = ? AND our_category_id = 0
\t\t\tORDER BY status DESC, mdate DESC
SQL
);
    define("CMD_SEL_SITECATEGORIES", <<<SQL
\t\tSELECT * FROM site_categories
\t\t\tWHERE site_id = ? AND our_category_id = 0
SQL
);
    global $db;
    $res =& $db->query(CMD_SEL_SITECATEGORIES, array($_REQUEST["siteId"]));
    if (PEAR::isError($res)) {
        printError($res);
        exit;
    }
    $categories = array();
    while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
        $catCount =& $db->getOne(CMD_SEL_ITEMSCOUNT, array($row->id));
        if (PEAR::isError($catCount)) {
            $catCount = 0;
        }
        $state = null;
        if ((int) $catCount > 0) {
            $state = "collapsed";
        }
        $customAttrs = array("siteId" => $_REQUEST["siteId"]);
        $categories[] = array("nodeId" => $row->id, "name" => $row->name, "state" => $state, "tp" => NODE_SITE_CATEGORY, "image" => getCategoryImageState($row), "customAttrs" => $customAttrs);
    }
    printTree($categories, true, true, "TreeCategories");
    print "<span id=\"siteId\" siteIdNum=\"" . $_REQUEST["siteId"] . "\" style=\"display: none;\"></span>";
}
开发者ID:rivetweb,项目名称:old-auto-catalog,代码行数:35,代码来源:HandleViewSite.php


示例3: test_printTree

 public function test_printTree()
 {
     $actual = '<li><a rel=site >site</a></li><li><h2>slug</h2><ul><li><a rel=0 >0</a></li><li><a rel=1 >1</a></li></ul></li><li><h2>query</h2><ul><li><a rel=comp >comp</a></li><li><a rel=category >category</a></li></ul></li>';
     $testArray = array('site' => 'dummy', 'slug' => array(0 => 'testkit', 1 => ''), 'query' => array('comp' => 'testcase', 'category' => '22ffa003527fc7b4cfddb491cbfb1804'));
     $result = printTree($testArray);
     //echo $result;
     $this->assertEquals($actual, $result);
 }
开发者ID:logiks,项目名称:logiks-core,代码行数:8,代码来源:test_helpers_listarray.php


示例4: deletes

function deletes($nestedSet, $deletes)
{
    foreach ($deletes as $delete) {
        $row = br()->db()->getRow('SELECT * FROM br_nested_set WHERE name = ?', $delete);
        br()->db()->table('br_nested_set')->remove($row['id']);
        $nestedSet->processDelete($row);
        printTree();
        $nestedSet->verify();
    }
}
开发者ID:jagermesh,项目名称:bright,代码行数:10,代码来源:BrNestedSet.php


示例5: printTree

function printTree($tree)
{
    if (!is_null($tree) && count($tree) > 0) {
        echo '<ul>';
        foreach ($tree as $node) {
            $dep_id = $node['name'][0];
            echo '<li onclick=\'display_info(' . $dep_id . ')\'>' . $node['name'][1];
            printTree($node['children']);
            echo '</li>';
        }
        echo '</ul>';
    }
}
开发者ID:anurag95,项目名称:SpinLogics,代码行数:13,代码来源:categories.php


示例6: printTree

function printTree($tree, $r = 0, $p = null)
{
    foreach ($tree as $i => $t) {
        $dash = $t['parent'] == 0 ? '' : str_repeat('-', $r) . ' ';
        printf("\t<option value='%d'>%s%s</option>\n", $t['id'], $dash, $t['name']);
        if ($t['parent'] == $p) {
            // reset $r
            $r = 0;
        }
        if (isset($t['_children'])) {
            printTree($t['_children'], ++$r, $t['parent']);
        }
    }
}
开发者ID:atonevbg,项目名称:snippets,代码行数:14,代码来源:snippets2.php


示例7: printTree

function printTree($tree, $r = 0, $p = null, $id)
{
    foreach ($tree as $i => $t) {
        $dash = $t->parent_id == 0 ? '' : str_repeat('----', $r) . ' ';
        $selected = $t->id == $id ? 'selected' : '';
        print "\t<option " . $selected . " value='" . $t->id . "'>" . $dash . $t->name . "</option>\n";
        if ($t->parent_id == $p) {
            //reset $r
            $r = 0;
        }
        if (isset($t->_children)) {
            $j = printTree($t->_children, $r + 1, $t->parent_id, $id);
        }
    }
    return $j;
}
开发者ID:ariborneo,项目名称:koperasi,代码行数:16,代码来源:tree_helper.php


示例8: printTree

function printTree($node, $indent, $prefix)
{
    $indentStr = "    ";
    $printStr = "";
    for ($i = 0; $i < $indent; $i++) {
        $printStr = $printStr . $indentStr;
    }
    echo $printStr . $prefix . " value: " . $node->data . "\n";
    $indent++;
    if ($node->left) {
        printTree($node->left, $indent, "left: ");
    }
    if ($node->right) {
        printTree($node->right, $indent, "right: ");
    }
}
开发者ID:bobbybouwmann,项目名称:ap-algorithms-bst,代码行数:16,代码来源:index.php


示例9: printTree

/**
 * Построение дерева
 */
function printTree($tree, $printUL = true, $isRoot = false, $name = "")
{
    if ($isRoot) {
        print '<ul id="' . $name . '" class="tree">';
    } else {
        if ($printUL) {
            print '<ul>';
        }
    }
    foreach ($tree as $item) {
        $img = "";
        $childsCode = "";
        // Имеются дочерние узлы
        if (isset($item["childs"]) && sizeof($item["childs"]) > 0) {
            $img = "collapsed";
            $childsCode = printTree($item["childs"]);
        } else {
            $img = "leaf";
        }
        if (isset($item["state"])) {
            $img = $item["state"];
        }
        $nodeType = isset($item["tp"]) ? " tp='" . $item["tp"] . "'" : "";
        $customImg = "";
        if (isset($item["image"])) {
            $imgAlt = "alt='" . basename($item["image"], ".png") . "'";
            $customImg = "<img src='" . $item["image"] . "' {$imgAlt}>";
        }
        $customAttrsCode = " ";
        if (isset($item["customAttrs"])) {
            $customAttrs = $item["customAttrs"];
            foreach ($customAttrs as $k => $v) {
                $customAttrsCode .= "{$k}=\"{$v}\" ";
            }
        }
        $liClass = isset($item["liClass"]) ? "class='" . $item["liClass"] . "'" : "";
        print "<li {$liClass}><img src='" . sprintf(TREE_IMAGE_MASK, $img) . "'>" . "<span nodeId='" . $item["nodeId"] . "'" . $nodeType . $customAttrsCode . ">" . $customImg . $item["name"] . "</span>" . $childsCode . "</li>";
    }
    if ($printUL) {
        print '</ul>';
    }
}
开发者ID:rivetweb,项目名称:old-auto-catalog,代码行数:45,代码来源:Misc.php


示例10: printTree

 function printTree($arr, $format = "ul,li,h2,a")
 {
     if (!is_array($format)) {
         $format = explode(",", $format);
     }
     for ($i = sizeOf($format); $i <= 4; $i++) {
         array_push($format, "span");
     }
     $s = "";
     foreach ($arr as $a => $b) {
         if (is_array($b)) {
             $s .= "<{$format[1]}><{$format[2]}>{$a}</{$format[2]}>";
             $s .= "<{$format[0]}>" . printTree($b, $format) . "</{$format[0]}>";
             $s .= "</{$format[1]}>";
         } else {
             $s .= "<{$format[1]}><{$format[3]} rel={$a} >{$a}</{$format[3]}></{$format[1]}>";
         }
     }
     return $s;
 }
开发者ID:logiks,项目名称:logiks-core,代码行数:20,代码来源:listarray.php


示例11: printTree

function printTree($tree, $keys, $prefix = '')
{
	if(is_array($tree))
	{
		foreach($tree as $key => $subTree)
		{
			if(in_array($key, $keys, true))
			{
				echo '- ' . $key . "\n";
			}
			elseif(!is_numeric($key))
			{
				$prefix .= '  ';
				echo $prefix . '|_ ' . $key . "\n";
			}
			printTree($subTree, $keys, $prefix);
		}
	}
	else
		echo $prefix . '|_ ' . $tree . "\n";
}
开发者ID:songjian,项目名称:songjian.github.io,代码行数:21,代码来源:tree.php


示例12: printTree

function printTree($tree, $root, $delim)
{
    reset($tree);
    #  print "<hr/>ROOT: $root<br/>";
    foreach ($tree as $node => $rec) {
        if (!in_array($node, $GLOBALS["nodesdone"])) {
            if (preg_match("#" . preg_quote($root) . "#i", $node)) {
                print '<li>';
                printf('<input type="checkbox" name="checkfolder[]" value="%s">&nbsp;', $node);
                print "<b>{$node}</b>\n";
                printf('<input type="checkbox" name="%s" id="%s" value="1"
          onchange="checkSubFolders(\'%s\');"> (add subfolders)', $node, $node, $node);
                print "</li>";
                print "<ul>\n";
                foreach ($tree[$node]["children"] as $leaf) {
                    if ($tree[$node . $delim . $leaf]) {
                        #          print "<ul>";
                        printTree($tree, $node . $delim . $leaf, $delim);
                        #          print "</ul>";
                    } else {
                        #  print "NO $node$delim$leaf <br/>";
                        print '<li>';
                        printf('<input type="checkbox" name="checkfolder[]" value="%s">&nbsp;', $node . $delim . $leaf);
                        #            print "$node.$delim";
                        print "{$leaf}</li>\n";
                    }
                    array_push($GLOBALS["nodesdone"], $node);
                }
                print "</ul>";
            } else {
                #     print "<li>$node</li>";
                #      print $root ."===". $node . "<br/>";
            }
        } else {
            #   print "<br/>Done: $node";
        }
    }
}
开发者ID:dehvCurtis,项目名称:phplist,代码行数:38,代码来源:import3.php


示例13: HandleExpand

function HandleExpand()
{
    global $db;
    if ($_REQUEST["treeId"] == "TreeCategories") {
        $res =& $db->query(CMD_SEL_ITEMS, array($_REQUEST["nodeId"]));
        if (PEAR::isError($res)) {
            printErr($res);
            exit;
        }
        $items = array();
        while ($row =& $res->fetchRow(DB_FETCHMODE_OBJECT)) {
            $customAttrs = array("categId" => $row->category_id);
            $items[] = array("nodeId" => $row->id, "name" => $row->art . " - " . $row->name, "state" => "item", "tp" => NODE_SITE_ITEM, "image" => getImageState($row), "customAttrs" => $customAttrs);
        }
        printTree($items, false);
    } else {
        if ($_REQUEST["treeId"] == "TreeOurSite") {
            $res =& $db->query(CMD_SEL_SUBCATEGORIES, array($_REQUEST["nodeId"]));
            if (PEAR::isError($res)) {
                printError($res);
                exit;
            }
            $categories = array();
            while ($row =& $res->fetchRow(DB_FETCHMODE_OBJECT)) {
                $catCount = getItemsCount($row->id);
                $state = null;
                if ($catCount > 0) {
                    $state = "collapsed";
                }
                $imgState = $row->viewmode == true ? "pics/ourcategoryHidden.png" : "pics/ourcategory.png";
                $categories[] = array("nodeId" => $row->id, "name" => $row->name, "state" => $state, "image" => $imgState);
            }
            addMovedItems($categories, $_REQUEST["nodeId"]);
            printTree($categories, false);
        }
    }
}
开发者ID:rivetweb,项目名称:old-auto-catalog,代码行数:37,代码来源:HandleExpand.php


示例14: simplexml_load_file

<?php

$cubename = $_GET['cube'];
include "../config.php";
include "views/views.php";
$xml = simplexml_load_file($xmlfile);
printTree($cubename, $img_cube, $img_plus);
开发者ID:apmuthu,项目名称:phpMyOLAP,代码行数:7,代码来源:tree.php


示例15: printTree

						<div class="col-md-4">							
							<select class="col-md-12 full-width-fix" name="link" id="link">								
								<option value="0">Unidentify</option>
								<?php 
printTree($link, '', '', $parsing->resource_id);
?>
							</select>
						</div>
					</div>
					<div class="form-group">
						<label class="col-md-2 control-label">Parent:</label> 
						<div class="col-md-4">
							<select class="select2-01 col-md-12 full-width-fix" name="parent" id="parent">
							<option value="0">Unidentify</option>
							<?php 
printTree($menu_parent, '', '', $parsing->id);
?>
							</select>
						</div>
					</div>
					<div class="form-group">
						<label class="col-md-2 control-label">Active:</label> 
						<div class="col-md-4">
							<select name="active" id="active" class="form-control">
								
								<option <?php 
if ($parsing->active == 0) {
    echo "selected";
} else {
    echo "";
}
开发者ID:ariborneo,项目名称:koperasi,代码行数:31,代码来源:menu-edit.php


示例16: array

$res =& $db->query(CMD_SEL_SUBCATEGORIES, array(0));
if (PEAR::isError($res)) {
    print $res->getMessage();
    exit;
}
$categories = array();
while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
    $catCount = getItemsCount($row->id);
    $state = null;
    if ($catCount > 0) {
        $state = "collapsed";
    }
    $imgState = $row->viewmode == true ? "pics/ourcategoryHidden.png" : "pics/ourcategory.png";
    $categories[] = array("nodeId" => $row->id, "name" => $row->name, "state" => $state, "image" => $imgState);
}
printTree($categories, true, true, "TreeOurSite");
?>

<script>

var ourSiteObj = document.getElementById("OurSite");

var getSrcNodesParam = function (nodes) {
	var res = "";
	if (nodes == null) return res;
	if (nodes.length == 0) return res;

	for (var i = 0; i < nodes.length; i++) {
		var nodeType = nodes[i].getAttribute("tp");
		if (nodeType == null) {
			nodeType = "";
开发者ID:rivetweb,项目名称:old-auto-catalog,代码行数:31,代码来源:OurSite.php


示例17: PrintTree

function PrintTree($tree, $level)
{
    MarkTime("PrintTree()");
    if (!is_null($tree) && count($tree) > 0) {
        $level++;
        foreach ($tree as $node) {
            PrintPipelineRow($GLOBALS['info'][$node['pipeline_id']], $level);
            #PrintPipelineRow(GetPipelineInfo($node['pipeline_id']), $level);
            $level = printTree($node['child_id'], $level);
        }
        $level--;
    }
    return $level;
}
开发者ID:pmolfese,项目名称:nidb,代码行数:14,代码来源:pipelines.php


示例18: printTree

						<label class="col-md-2 control-label">Link:</label> 
						<div class="col-md-4">							
							<select class="col-md-12 full-width-fix" name="link" id="link">								
								<?php 
printTree($link);
?>
							</select>
						</div>
					</div>
					<div class="form-group">
						<label class="col-md-2 control-label">Parent:</label> 
						<div class="col-md-4">
							<select class="col-md-12 full-width-fix" name="parent" id="parent">								
								<option value='0'>No Parent</option>
								<?php 
printTree($menu_parent);
?>
							</select>
						</div>
					</div> 
					<div class="form-group">
						<label class="col-md-2 control-label">Active:</label> 
						<div class="col-md-4">
							<select name="active" id="active" class="form-control">								
								<option value="0">Active</option>
								<option value="1">Inactive</option>							
							</select>
						</div>
					</div>	
					<div class="form-actions">
						<div class="row">						
开发者ID:ariborneo,项目名称:koperasi,代码行数:31,代码来源:menu-add.php


示例19: printTreeList

 function printTreeList($treeArray)
 {
     if (sizeOf($treeArray) <= 0) {
         return "";
     }
     $s = "";
     foreach ($treeArray as $a => $b) {
         $data = $b['data'];
         unset($b['data']);
         if (count($b) > 0) {
             $s .= "<li>";
             $s .= "<h3 rel='{$data['id']}'>{$a}</h3>";
             $s .= "<ul>";
             $s .= printTree($b);
             $s .= "</ul>";
             $s .= "</li>";
         } else {
             $s .= "<li><a rel='{$data['id']}'>{$a}</a></li>";
         }
     }
     return $s;
 }
开发者ID:kshyana,项目名称:Logiks-Core,代码行数:22,代码来源:sqlprint.php


示例20: printEditor

function printEditor($ndid, $tree, $test)
{
    $data = mysqli_query($tree, "SELECT * FROM nodes WHERE id='" . $ndid . "'");
    $info = mysqli_fetch_array($data, MYSQLI_ASSOC);
    echo "<form method=\"POST\" action=\"/\">\n";
    echo " <div><input type=\"text\" id=\"id\" name=\"id\" placeholder=\"id\" value=\"" . $info["id"] . "\"/></div>\n";
    echo " <div><input type=\"text\" id=\"title\" name=\"title\" placeholder=\"title\" value=\"" . $info["title"] . "\"/></div>\n";
    echo " <div><input type=\"text\" id=\"description\" name=\"description\" placeholder=\"description\" value=\"" . $info["description"] . "\"/></div>\n";
    echo " <div><textarea id=\"body\" name=\"body\" placeholder=\"body\">" . $info["body"] . "</textarea></div>\n";
    echo " <div><input type=\"text\" id=\"images\" name=\"images\" placeholder=\"images\" value=\"" . $info["images"] . "\"/></div>\n";
    echo "<div id=\"tree\">\n";
    printTree($test, "/", 1);
    echo "</div>\n\n";
    echo " <div><input type=\"text\" id=\"connections\" name=\"connections\" placeholder=\"connections\" value=\"" . $info["connections"] . "\"/></div>\n";
    echo " <input type=\"hidden\" id=\"edit\" name=\"edit\" value=\"" . $ndid . "\"/>\n";
    echo " <div><input type=\"submit\" value=\"Save\"/></div>\n";
    echo "</form>\n";
}
开发者ID:ixias,项目名称:web-thing,代码行数:18,代码来源:lib.php



注:本文中的printTree函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP printUrl函数代码示例发布时间:2022-05-15
下一篇:
PHP printText函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap