Here is a good example. Play with it a bit.
<?php
$cds = array(
'Christina Aguilera'=>array(
'Impossible',
'Beautiful',
'Dirrty'
),
'Pink'=>array(
'Just like a pill',
'Family potrait',
'Missundaztood'
),
'Kelly Rowland'=>array(
'Stole',
'Obsession',
'Past 12'
)
);
echo '<p><b>How many CDs in our collection?</b><br />
There are '.sizeof($cds)." CDs in our collection.</p>\n";
echo "<ol>\n";
foreach( $cds as $singer=>$songs )
{
echo ' <li><b>'.$singer."</b>.<br />\n";
echo " <em>Songs</em>: </li>\n";
echo " <ul>\n";
asort( $songs ); // sorts the list of songs
foreach( $songs as $song )
{
echo ' <li>'.$song.".</li>\n";
}
echo " </ul>\n";
}
echo "</ol>\n";
?>