コード例 #1
0
function &_get_cat_children($category_id, $categories)
{
    if (empty($categories)) {
        return array();
    }
    $category_list = array();
    foreach ($categories as $category) {
        if ($category->cat_ID == $category_id) {
            continue;
        }
        if ($category->category_parent == $category_id) {
            $category_list[] = $category;
            if ($children = _get_cat_children($category->cat_ID, $categories)) {
                $category_list = array_merge($category_list, $children);
            }
        }
    }
    return $category_list;
}
コード例 #2
0
function &_get_cat_children($category_id, $categories) {
	if ( empty($categories) )
		return array();

	$category_list = array();
	$has_children = _get_category_hierarchy();

	if  ( ( 0 != $category_id ) && ! isset($has_children[$category_id]) )
		return array();

	foreach ( $categories as $category ) {
		if ( $category->cat_ID == $category_id )
			continue;

		if ( $category->category_parent == $category_id ) {
			$category_list[] = $category;

			if ( !isset($has_children[$category->cat_ID]) )
				continue;

			if ( $children = _get_cat_children($category->cat_ID, $categories) )
				$category_list = array_merge($category_list, $children);
		}
	}

	return $category_list;
}