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, 7238👍, 0💬
Popular Posts:
Can two catch blocks be executed? No, once the proper catch section is executed the control goes fin...
I have 5 questions please give me the answer ,explanation,suggestions if any?? what is PMP(project m...
How do you locate the first X in a string txt? A) txt.find('X'); B) txt.locate('X'); C) txt.indexOf(...
What print out will the folloging code produce? main() { char *p1=“name”; char *p2; p2=(char*)malloc...
What does XmlValidatingReader class do? XmlTextReader class does not validate the contents of an XML...