static public function get($parentid = 0, $array = array(), $level = 0, $add = 2, $repeat = ' ') {
$str_repeat = '';
if ($level) {
for($j = 0; $j < $level; $j ++) {
$str_repeat .= $repeat;
}
}
$newarray = array ();
$temparray = array ();
foreach ( ( array ) $array as $v ) {
if ($v ['parent_id'] == $parentid) {
$newarray [] = array ('id' => $v ['id'], 'catalog_name' => $v ['catalog_name'], 'catalog_name_alias' => $v ['catalog_name_alias'], 'parent_id' => $v ['parent_id'], 'level' => $level, 'sort_order' => $v ['sort_order'], 'seo_keywords' => $v ['seo_keywords'], 'seo_description' => $v ['seo_description'], 'attach_file' => $v ['attach_file'], 'attach_thumb' => $v ['attach_thumb'], 'status_is' => $v ['status_is'], 'data_count' => $v ['data_count'] , 'display_type' => $v ['display_type'], 'menu_is' => $v ['menu_is'],'template_list' => $v ['template_list'],'acl_browser' => $v ['acl_browser'],'acl_operate' => $v ['acl_operate'],'template_page' => $v ['template_page'],'template_show' => $v ['template_show'],'create_time' => $v ['create_time'], 'str_repeat' => $str_repeat, 'page_size'=>$v['page_size'] );
$temparray = self::get ( $v ['id'], $array, ($level + $add) );
if ($temparray) {
$newarray = array_merge ( $newarray, $temparray );
}
}
}
return $newarray;
}
以上代码在Catalog model里,没理解错应该是递归获取子栏目这类的
现在我调用这货
Catalog::get($catalogArr['id'],$catalogArr,2,2,'>>')
返回array(0) { }
$catalogArr`打印出来的内容`array(22) { ["id"]=> string(2) "11" ["catalog_name"]=> string(12) "工作动态" ["catalog_name_alias"]=> string(4) "gzdt" ["parent_id"]=> string(1) "0" ["level"]=> int(0) ["sort_order"]=> string(1) "1" ["seo_keywords"]=> string(12) "工作动态" ["seo_description"]=> string(12) "工作动态" ["attach_file"]=> string(0) "" ["attach_thumb"]=> string(0) "" ["status_is"]=> string(1) "Y" ["data_count"]=> string(1) "0" ["display_type"]=> string(4) "list" ["menu_is"]=> string(1) "N" ["template_list"]=> string(9) "list_text" ["acl_browser"]=> string(0) "" ["acl_operate"]=> string(0) "" ["template_page"]=> string(9) "list_page" ["template_show"]=> string(9) "show_post" ["create_time"]=> string(10) "1409390084" ["str_repeat"]=> string(0) "" ["page_size"]=> string(2) "10" }
问我这样调用对吗》?为什么获取不了子栏目
贴一个我的代码:
楼主可以看下