Source Code:
(back to article)
<?php // Example 1 $array = ["apple", "banana", "cherry"]; foreach ($array as $value): echo $value . PHP_EOL; endforeach; // Output: // apple // banana // cherry // Example 2 $array = ["a" => "apple", "b" => "banana", "c" => "cherry"]; foreach ($array as $key => $value): echo $key . " = " . $value . PHP_EOL; endforeach; // Output: // a = apple // b = banana // c = cherry
Result:
Report an issue