0

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.

1 Answer 1

7

You’re using <li> instead of </li> as closing tag. Use the proper closing tag and it should work:

echo '<li>' . $title . '</li>';
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.