html - How to loop through an array and print each item into an <li> tag using PHP? -


i'm trying iterate through array using php. want items stored in <li> tag. i'm having trouble getting names print out. can count of array items printed, not names.

    <ul>     <?php          $names = array('mike', 'chris', 'jane', 'bob');         for($i=0; $i < count($names); $i++) {             echo "<li>" . $i . "</li>";         }     ?> </ul> 

<ul> <?php      $names = array('mike', 'chris', 'jane', 'bob');     foreach($names $name) {         echo "<li>" . $name . "</li>";     } ?> </ul> 

Comments

Popular posts from this blog

python - TypeError: start must be a integer -

html - How can i make an element from a bottom stacking context stays in front of another higher stacking context? -

html - href attribute breaking an element -