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, 7559👍, 0💬
Popular Posts:
What is the difference between delegate and events? ã Actually events use delegates in bottom. But ...
What is difference between ADPATCH and OPATCH ? # ADPATCH is utility to apply ORACLE application Pat...
Can you explain why your project needed XML? Remember XML was meant to exchange data between two ent...
Can JavaScript steal text from your clipboard? It is true, text you last copied for pasting (copy &a...
How To Use an Array as a Queue? - PHP Script Tips - PHP Built-in Functions for Arrays A queue is a s...