I have changed version of this recursive function... http://www.phpbuilder.com/articles/databases/mysql/handling-hierarchical-data-in-mysql-and-php.html
What I need is a way to save the returned value of this function in an array so that I can reverse the order of array elements. The function works well for me, but I need a way to save values. Here is the code...
function display_children($category_id, $level) {
global $database;
$result = mysql_query("SELECT * FROM parents WHERE id_roditelja='$category_id'") or die(mysql_error());
$niz = array();
while ($row = mysql_fetch_array($result)) {
echo str_repeat(' ', $level) . $row['naziv'] . "<br/>";
array_push($niz, display_children($row['parent_id'], $level + 1));
//this is one way I tried, and I get $niz with exact number of elements but each is null
//in this $niz array I need to store values of recursion
var_dump($niz);
}
}