无限分类获取当前位置的函数
程序员文章站
2022-06-08 10:08:02
...
php代码
<?php /* * @name pcb_article_position * @access public * @param int $id * @param string $split * @return string */ function pcb_article_position ($id, $split=" » ") { global $mysql, $system_webpath; $array = array(); $string = ''; do { $temp = $mysql->fetch("SELECT `id`, `parent_id`, `name` FROM `pcb_article_category` WHERE `id` = " . $id . " LIMIT 1"); $array[] = $temp; $id = $temp['parent_id']; } while ($temp['parent_id'] != 0); /* * @按二维数组key的降序重新排序 */ krsort($array); foreach ($array as $value) { $string .= $split . "<a href='" . $system_webpath . "/article/list-id-" . $value['id'] . "-page-1.html' title='" . $value['name'] . "'>" . $value['name'] . "</a>"; } return $string; } ?>