Skip navigation.
Home

Add new comment

Whoops. It should probably

Whoops. It should probably look like this:

<?php
function printMenu(&$children)
{
    
// HTML here for the sake of example. Normally I would avoid
    // this. :)
    
echo '<ul>';
    foreach (
$children as $id => $child)
    {
        echo
'<li>';
        if (
$child['URL'] != null) {
            
printf('<a href="%s" id="%s">%s</a>',$child['URL'],
                
htmlentities($id),htmlentities($child['name']));
        } else {
            
printf('%s',htmlentities($child['name']));
        }
        echo
"\n"; // so we have some nice HTML :)
        
        // here's the recursion.
        
if (count($child['children']))
            
printMenu($child['children']);
        
        echo
'</li>';     
    }
    echo
"</ul>\n";
}
?>

Reply




*

  • Web and e-mail addresses are automatically converted into links.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <pre> <p> <br /> <br>