PHP program to print each element of an array:
The below program is to print each element of an array using foreach() loop. The PHP echo statement is used to output the result on the screen. An array is a single variable which can store multiple values at a time.
Example
<!DOCTYPE html> <html> <body> <?php $cars = array("BMW", "Ford", "Hyundai", "Jaguar"); foreach ($cars as $value) { echo "$value <br>"; } ?> </body> </html> |
Output
BMW Ford Hyundai Jaguar |