...

View Full Version : Anyone know how to do this PHP?



phpnoob91
04-10-2012, 09:10 PM
1) Create a variable called $artist_songs and give it the value of an associative
array where the keys are the artist names from the first exercise, and the values are
arrays of songs by the artist. Include at least three songs by each artist:
$artist_songs=array(
'Iron Maiden' => array('Invasion', 'Run to the Hills', 'Aces High'),
'Carly Simon' => ....
2) Loop through $artist_songs using foreach and output a div for each artist. Show
the artist name in bold and put the songs in an unordered list:
<div>
<b>Iron Maiden</b>
<ul>
<li>Invasion</li>
<li>Run to the Hills</li>
<li>Aces High</li> </ul>
</div>
<div>
<b>Carly Simon</b>
...etc

Fou-Lu
04-10-2012, 09:22 PM
What have you tried so far? This is a single multi-dimensional array and will require two foreach iterations, or one foreach and an implosion.

Also, in the future please select a title that is more suitable to the question at hand.

angst
04-10-2012, 09:23 PM
sounds like school home work to me....

Fou-Lu
04-10-2012, 09:29 PM
sounds like school home work to me....

Me as well, which is why I'd like to see where the OP is at before suggesting solutions.

tangoforce
04-11-2012, 12:35 AM
1) Create a variable called $artist_songs and give it the value of an associative
array where the keys are the artist names from the first exercise

Yup, definitely homework!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum