Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

Write value from function into array

$
0
0

Hi,

I have problem with recursive function. I want to store value form that function into array because i need to reverse result of function. 

Here is function 

function display_children($category_id, $level) 
{
  global $database;
    $result = mysql_query("SELECT * FROM parents WHERE id_roditelja='$category_id'") or die(mysql_error());
    
   $broj = $database->num_rows($result);
    $niz = array();
while ($row = mysql_fetch_array($result)) 
    {
        echo str_repeat('  ',$level) . $row['naziv'] . "-> ";
      
      $niz =  display_children($row['parent_id'], $level+1); 
        }
    
}

I just want to save  "display_children($row['parent_id'], $level+1)" this into an array reverse it and then return it. Can someone help me with this? 


Viewing all articles
Browse latest Browse all 13200

Trending Articles