The foreach loop is mainly used for looping through the values of an array. It loops over the array, and each value for the current array element is assigned to $value, and the array pointer is advanced by one to go the next element in the array.


foreach (array as $value){ 
  //code to be executed; 



foreach($salary as $value){
  echo "Salary: $value<br>";

Program Output:

Salary: 2000

Salary: 3000

Salary: 5000

Found This Page Useful? Share It!
Get the Latest Tutorials and Updates
Join us on Telegram