PHP: Simple PHP loop

How to loop through an array of items in PHP.
This PHP loop iterates an array of cars.
A PHP loop can be used for running the same code more than once.
The array pointer is advanced by one, and goes to the next element in the array at each itteration.

$car = ["BMW, "Mercedes", "Audi", "Chevrolet"];
foreach($cars as $car) {
  echo "Car: $car<br>";
}

Leave a Reply

Your email address will not be published. Required fields are marked *