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

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

PHP中文网
PHP中文网Original
2016-05-25 17:09:301156browse

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;

}
?>
Statement:
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
Previous article:参数过滤类Next article:图片缩略水印类