Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
How To Get the Minimum or Maximum Value of an Array
How To Get the Minimum or Maximum Value of an Array? - PHP Script Tips - PHP Built-in Functions for Arrays
✍: FYIcenter.com
If you want to get the minimum or maximum value of an array, you can use the min() or max() function. Here is a PHP script on how to use min() and max():
<?php $array = array(5, 7, 6, 2, 1, 3, 4, 2); print("Minimum number: ".min($array)."\n"); print("Maximum number: ".max($array)."\n"); $array = array("Zero"=>"PHP", "One"=>"Perl", "Two"=>"Java"); print("Minimum string: ".min($array)."\n"); print("Maximum string: ".max($array)."\n"); ?>
This script will print:
Minimum number: 1 Maximum number: 7 Minimum string: Java Maximum string: Perl
As you can see, min() and max() work for string values too.
2007-04-22, 7378👍, 0💬
Popular Posts:
How To Use Subqueries with the IN Operator? - MySQL FAQs - SQL SELECT Statements with JOIN and Subqu...
How To Recover a Dropped Index? - Oracle DBA FAQ - Managing Oracle Table Indexes If you have the rec...
What will be printed as the result of the operation below: main() { int x=20,y=35; x=y++ + x++; y= +...
How do I use a scriptlet to initialize a newly instantiated bean? A jsp:useBean action may optionall...
How To Process Query Result in PL/SQL? - Oracle DBA FAQ - Introduction to PL/SQL You can run queries...