Source Code:
(back to article)
<?php /** * @var array[string => int] $scores An associative array of strings (player names) as keys and integers (scores) as values. */ $scores = array("Player 1" => 100, "Player 2" => 200, "Player 3" => 300); /** * Function to output the contents of the $scores array. */ function outputScores() { global $scores; foreach ($scores as $player => $score) { echo $player . ": " . $score . "\n"; } } outputScores(); ?>
Result:
Report an issue