xxxxxxxxxx
$array = array('a', 'b', 'c');
foreach ($array as $letter=>$index) {
echo $letter; //Here $letter content is the actual index
echo $array[$letter]; // echoes the array value
}//foreach
xxxxxxxxxx
$myArray = ['apple', 'banana', 'orange'];
foreach ($myArray as $index => $value) {
echo "Index: " . $index . ", Value: " . $value . "\n";
}
xxxxxxxxxx
$array = ['apple', 'banana', 'orange'];
foreach ($array as $index => $value) {
echo "Index: $index, Value: $value\n";
}