For each key and value pair from associative array in PHP
Description
The following code shows how to for each key and value pair from associative array.
Example
<?php// w w w.ja va 2s. co m
$links = array("Apache Web Server" => "www.apache.org",
"Tutorial" => "www.java2s.com",
"The PHP Scripting Language" => "www.php.net");
foreach($links as $title => $link) {
echo "<a href=\"http://$link\">$title</a><br />";
}
?>
The code above generates the following result.