Question
Please complete this using php and html. NOTE: PUT THE PRINTING OF THE TABLE IN A FUNCTION!!! Then call the function as many times as
Please complete this using php and html.
NOTE: PUT THE PRINTING OF THE TABLE IN A FUNCTION!!! Then call the function as many times as necessary to complete the tasks below.
a)Create a one dimensional associative array that has at least 10 key/element pairs.
b)Print out the array in a table, printing out keys and values (use html)
c) Look at your array. Come up with some criterion about elements in your array, so that about half the elements meet the criterion and half don't. For example, if your elements are strings, your criterion might be (< "kangaroo"), or if your elements are numbers, your criterion might be (> 89)! Print out only those array elements that meet the criterion. Put the criterion in a php comment before the code so that I can see it!
d)Sort the array (using a function call -- do not write the sorting code yourself!!!) Look up the sort function and the asort function in www.php.net. Print out the sorted array in table form, printing out keys and values.
e) unset the fourth element in the sorted array (use the unset function, look it up on www.php.net)
f) Print out the reverse sorted array in table form, printing out keys and values. Look up rsort and arsort on www.php.net
g) Print out the array sorted by KEY value in table form, (look up other sort functions) printing out keys and values.
h) 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!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started