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