How can a PHP foreach loop be structured to output values as list items within a ul element in HTML?

To output values as list items within a ul element in HTML using a PHP foreach loop, you can iterate over an array of values and echo each value wrapped in an li tag. This will create a list item for each value within the ul element.

<ul>
<?php
$items = ["Item 1", "Item 2", "Item 3"];

foreach ($items as $item) {
    echo "<li>$item</li>";
}
?>
</ul>