PHP,HTML,CSS

Arrays, loops & functions

  1. Make a PHP associative array out of the following data. Use PHP's print_r function discussed in class to see if it worked!
          
                                    7    computer science
                                    5    Sewanee
                                    2    frogs
                                    6    CSCI
                                    9    computers
                                    4    applejack
                                    6    MySQL
                                    4    Star-Puppy
                                    5    USS Enterprise
                                    7    dogs
                                    1    buffalo
                                    5    ardvaark
                                    2    Lizard
                                    9    PHP
                                    4    jQuery
                                    6    star fleet
                                    8    Spock
    
          

    Load your page to check that it works! Has no errors!

     

  2. Now use a PHP loop to generate an unordered (<ul>) HTML list of the array contents

    • 7 computer science
    • 5 Sewanee
      etc.

       

    Reload your page to check works/no errors!

  3. Now add an <hr> to your file and MAKE ANOTHER PHP loop almost the same as the previous one but instead of printing the number in the list it instead uses that number in some way to set the font size of the list item, as in this example...
                      <li style="font-size:1.7em"> computer science </li> 
                      <li style="font-size:1.5em"> Sewanee </li> 
                      etc.
                

    I know I know but...
    For just this one time, use the inline styling. It's necessary for the future bits of code to work. You'll see why soon.

    Reload your page to check works/no errors!