Foreach loop returning null values in PHP?
        Posted  
        
            by Jascha
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Jascha
        
        
        
        Published on 2010-03-20T15:30:40Z
        Indexed on 
            2010/03/20
            15:41 UTC
        
        
        Read the original article
        Hit count: 379
        
Hello,
I have a pretty simple problem.
Basically I have an array called $list that is a list of titles.  If I do a print_r($list) I get these results:
Array ( [0] => Another New Title [1] => Awesome Movies and stuff [2] => Jascha's Title )
Now, I'm running a foreach loop to retrieve their values and format them in an <ul> like so...
function get_film_list(){
    global $categories;
    $list = $categories->get_film_list();
    if(count($list)==0){
        echo 'No films are in this category';
    }else{
        echo '<ul>';
        foreach($list as $title){
           echo '<li>' . $title . '<li>';
        }
        echo '</ul>';
    }
}
The problem I'm having is my loop is returning two values per value (is it the key value?) The result of the preceding function looks like this:
- Another New Title
 - Awesome Movies and stuff
 - Jascha's Title
 
I even tried:
foreach($list as $key => $title){
    echo '<li>' . $title . '<li>';
}
With the same results:
- Another New Title
 - Awesome Movies and stuff
 - Jascha's Title
 
What am I missing here?
Thanks in advance.
© Stack Overflow or respective owner