Функция не возвращает массив
Код:
function func($id=0,$level=0)
{
global $dir;
$q = mysql_query("SELECT * FROM sections WHERE section_id='$dir[$level]' AND p_id='$id'");
if (mysql_num_rows($q)>0)
{
$SECTION = mysql_fetch_array($q);
$level = $level+1;
if ($level==count($dir)) { return $SECTION; }
func($SECTION[section_id],$level);
}
}
{
global $dir;
$q = mysql_query("SELECT * FROM sections WHERE section_id='$dir[$level]' AND p_id='$id'");
if (mysql_num_rows($q)>0)
{
$SECTION = mysql_fetch_array($q);
$level = $level+1;
if ($level==count($dir)) { return $SECTION; }
func($SECTION[section_id],$level);
}
}
Код:
function func($id=0,$level=0)
{
... {
if (...) return $ret;
$ret=func($SECTION[section_id],$level);
}
...
return $ret;
}
{
... {
if (...) return $ret;
$ret=func($SECTION[section_id],$level);
}
...
return $ret;
}