#1 homexigua
require('Category.class.php');//导入Category.class.php类//测试数据
$data[]=array('cat_id'=>1,'pid'=>0,'name'=>'中国');
$data[]=array('cat_id'=>2,'pid'=>0,'name'=>'美国');
$data[]=array('cat_id'=>3,'pid'=>0,'name'=>'韩国');
$data[]=array('cat_id'=>4,'pid'=>1,'name'=>'北京');
$data[]=array('cat_id'=>5,'pid'=>1,'name'=>'上海');
$data[]=array('cat_id'=>6,'pid'=>1,'name'=>'广西');
$data[]=array('cat_id'=>7,'pid'=>6,'name'=>'桂林');
$data[]=array('cat_id'=>8,'pid'=>6,'name'=>'南宁');
$data[]=array('cat_id'=>9,'pid'=>6,'name'=>'柳州');
$data[]=array('cat_id'=>10,'pid'=>2,'name'=>'纽约');
$data[]=array('cat_id'=>11,'pid'=>2,'name'=>'华盛顿');
$data[]=array('cat_id'=>12,'pid'=>3,'name'=>'首尔');
$cat=new Category(array('cat_id','pid','name','cname'));
$s=$cat->getTree($data);//获取分类数据树结构
//$s=$cat->getTree($data,1);获取pid=1所有子类数据树结构
foreach($s as $vo)
{
echo $vo['cname'].'
';
}
*/
Category.zip
2011-12-01 14:32:14