PHP获取栏目的所有子级和孙级栏目的ID号示例

前端之家收集整理的这篇文章主要介绍了PHP获取栏目的所有子级和孙级栏目的ID号示例前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

<div class="codetitle"><a style="CURSOR: pointer" data="22823" class="copybut" id="copybut22823" onclick="doCopy('code22823')"> 代码如下:

<div class="codebody" id="code22823">
//@获取子栏目ID号
private function sonCategoryIds($categoryID)
{
//@初始化栏目数组
$array[] = $categoryID; do
{
$ids = '';
$temp = $this->MysqL->select('SELECT id FROM pcb_article_category WHERE parentID IN (' . $categoryID . ')');
foreach ($temp as $v)
{
$array[] = $v['id'];
$ids .= ',' . $v['id'];
}
$ids = substr($ids,1,strlen($ids));
$categoryID = $ids;
}
while (!empty($temp)); $ids = implode(',',$array); return $ids;
}

猜你在找的PHP相关文章