PHP provides an easy way to use every element of an array with the Foreach statement.
Example
$employeeAges;
$employeeAges["Hoang"] = "28";
$employeeAges["Thao"] = "19";
$employeeAges["Tuan"] = "25";
$employeeAges["Mai"] = "26";
$employeeAges["Hoa"] = "32";
foreach( $employeeAges as $key => $value){
echo "Name: $key, Age: $value
";
}
$something as $key => $value
The operator "=>" represents the relationship between a key and value. Example, we only changed the variable names that refer to the keys and values
$employeeAges;
$employeeAges["Hoang"] = "28";
$employeeAges["Thao"] = "19";
$employeeAges["Tuan"] = "25";
$employeeAges["Mai"] = "26";
$employeeAges["Hoa"] = "32";
foreach( $employeeAges as $name=> $age){
echo "Name: $name, Age: $age
";
}