Create a unordered HTML list from array elements

Views: 54 Last modified: September 17th, 2011 Comments: 0

This snippet will create a unordered HTML list out of the array elements. You can put anything in this array what you want to appear in the list.

// Fill a array with values
$level = array('List item 1', 'List item 2', 'List item 3');

/*
* echo the start(open) unordered HTML element
* After that, loop through each array element
* For the closure, echo the closing unordered HTML element
*/
echo '<ul>';
foreach ($level as $item)
{
	echo '<li>'. $item .'</li>';
}
echo '</ul>';
VN:F [1.9.13_1145]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.13_1145]
Rating: 0 (from 0 votes)

    Mail this!

    To: From:Sum {4+7} =  
    Anything to add ?

        You must be logged in to post a comment.