Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Apr 2012
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question Anyone know how to do this PHP?

    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

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    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.

  • #3
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    sounds like school home work to me....

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Quote Originally Posted by angst View Post
    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.

  • #5
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,310
    Thanks
    58
    Thanked 525 Times in 512 Posts
    Blog Entries
    5
    Quote Originally Posted by phpnoob91 View Post
    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!
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •