What is the purpose of the foreach loop in the PHP script provided?

The purpose of the foreach loop in the PHP script is to iterate over each element in an array and perform a specific action on each element. In this case, the foreach loop is used to iterate over the $colors array and echo out each color.

$colors = array("red", "green", "blue");

foreach($colors as $color){
    echo $color . "<br>";
}