CodesJava

Easy learning with example program codes

PHP program to print each element of an array

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
Please follow and like us:
error
Posted in PHP   








Copyright © 2019 CodesJava DMCA.com Protection Status