Question: I could use some help with this problem for my html class. NOTE: PUT THE PRINTING OF THE TABLE IN A FUNCTION!!! Then call the
I could use some help with this problem for my html class.
NOTE: PUT THE PRINTING OF THE TABLE IN A FUNCTION!!! Then call the function as many times as necessary to complete the tasks below.
Create a PHP file
Part I
a.) Declare a one dimensional associative array that has at least 8 key/element pairs.
b ) Print out the array in a table, printing out keys and values (use html as you did in Lab 1).
c.) Print out the sorted array in table form, printing out keys and values.
d.) unset the second element in the sorted array (use the unset function, look it up on php.net)
e.) Print out the reverse sorted array in table form, printing out keys and values.
f.) Print out the array sorted by KEY value in table form, printing out keys and values.
g.) EXTRA CREDIT: use the array_rand function to print out 3 random elements of the array. Remember that every time you refresh your page, these will be different!
Part II
Create a two dimensional array that contains the following information about twitter users: (HINT: the second dimension should be associative, with keys tweets, followers, following. These refer to the number of tweets the user tweeted, how many followers the user has and how many other users this user is following! (The first dimension can be indexed, and you can add Username to the second dimension, or you can have both dimensions be associative, where the Username points to the first person etc. In this case the key joeDoe, for example, has the value array(tweets=>20000,followers=>45,following=>8)
| Handle (Username) | Tweets | Number of Followers | Following |
| joeDoe | 20000 | 45 | 8 |
| JohnD | 62000 | 123 | 160 |
| computerSavy | 75 | 1 | 25 |
| myTwitterAccount | 1800 | 15 | 6 |
a.) Print out the array sorted by tweets (ascending)
b.) Print out the Username of the user with the most followers
c.) Print out only users who have followers > 10, sorted by followers in descending order.
d.) EXTRA CREDIT: Print out the total (sum) of all tweets for all Usernames in the table.
I am a Novice at PHP and HTML, I appreciate all help, Thank you!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
