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 -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -