What are the advantages of using foreach loop over traditional for loop in PHP for iterating through arrays?

When iterating through arrays in PHP, using a foreach loop is often more concise and easier to read compared to a traditional for loop. The foreach loop automatically handles the iteration over each element in the array without the need for manual indexing or incrementing. This can lead to cleaner and more maintainable code, especially when working with multidimensional arrays or associative arrays.

// Using foreach loop to iterate through an array
$colors = array("red", "green", "blue");

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