key: Fetch a key from an associative array : Associate Array « Data Structure « PHP
- PHP
- Data Structure
- Associate Array
key: Fetch a key from an associative array
<?php
$capitals = array("Ohio" => "Columbus", "Iowa" => "Des Moines","Arizona" => "Phoenix");
echo "<p>Can you name the capitals of these states?</p>";
while($key = key($capitals)) {
echo $key."<br />";
next($capitals);
}
?>
Related examples in the same category