assoc-array.php

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Associative Arrays</title>
    <meta charset="utf-8">
  </head>
  <body>
    <?php
    $flowers = array(
	"Rose" => "red",
	"Carnation" => "pink",
	"Lily" => "white",
	"Peony" => "lavender",
	"Violet" => "violet"
    );
    $flowers["Daffodil"] = "yellow";
    ?>
<pre>
<?php
    print_r($flowers);
    ksort($flowers);		# sort array by key
?>
</pre>
  <ul>
  <?php
    foreach( $flowers as $name => $color ):
	print "<li>$name is $color</li>\n";
    endforeach;
  ?>
  </ul>
  </body>
</html>