How can a foreach loop be utilized to iterate through the array and display all values in the given context?

To iterate through an array and display all its values using a foreach loop in PHP, you can simply use the foreach loop to loop through each element of the array and display the value in each iteration. This allows you to easily access and display all values in the array without needing to manually specify the index of each element.

// Sample array
$colors = array("Red", "Green", "Blue");

// Iterate through the array and display all values
foreach ($colors as $color) {
    echo $color . "<br>";
}