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, 7540👍, 0💬
Popular Posts:
.NET INTERVIEW QUESTIONS - What is the difference between thread and process? A thread is a path of ...
How can you write a loop indefinitely? Two examples are listed in the following code: for(;;) { ... ...
How can I search for data in a linked list? Unfortunately, the only way to search a linked list is w...
How do you handle change request? Normally change request are handled by preparing an Impact analysi...
If client side validation is enabled in your Web page, does that mean server side code is not run? W...