Home > php教程 > PHP源码 > 无限分类获取当前位置的函数

无限分类获取当前位置的函数

PHP中文网
Release: 2016-05-25 17:09:30
Original
1155 people have browsed it

php代码

<?php
/*
 * @name		pcb_article_position
 * @access		public
 * @param		int		$id
 * @param		string		$split
 * @return		string
 */
function pcb_article_position ($id, $split=" &raquo; ") {

	global $mysql, $system_webpath;

	$array = array();
	$string = &#39;&#39;;

	do {
		$temp = $mysql->fetch("SELECT `id`, `parent_id`, `name` FROM `pcb_article_category` WHERE `id` = " . $id . " LIMIT 1");
		$array[] = $temp;
		$id = $temp[&#39;parent_id&#39;];
	} while ($temp[&#39;parent_id&#39;] != 0);

	/*
	 * @按二维数组key的降序重新排序
	 */
	krsort($array);

	foreach ($array as $value) {

		$string .= $split . "<a href=&#39;" . $system_webpath . "/article/list-id-" . $value[&#39;id&#39;] . "-page-1.html&#39; title=&#39;" . $value[&#39;name&#39;] . "&#39;>" . $value[&#39;name&#39;] . "</a>";
	}

	return $string;

}
?>
Copy after login
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
Latest Articles by Author
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template