function build_path($cid)
{
static $fr=array();
$DB = new MySQLTable;
$DB->TblName = 'shop_categories';
$where['cat_id']['='] = $cid;
$res = $DB->Select('cat_id,cat_name,cat_parent', $where);
if($res !== false)
{
$pid = mysql_fetch_array($res);
if($pid['cat_parent'] !== "0")
{
$fr[] = $pid['cat_id'];
build_path($pid['cat_parent']);
} else {
$fr[] = $cid;
$fr = array_reverse($fr);
print_r($fr);
return $fr;
}
}
}
print_r(build_path(100));
Why is working print_r in function, but second print_r returns NULL?