Tools, FAQ, Tutorials:
Getting Minimum/Maximum Value of an Array in PHP
How To Get the Minimum or Maximum Value of an Array in PHP?
✍: 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.
⇒ Creating Your Own Functions in PHP
⇐ Splitting a String into an Array in PHP
2016-12-28, ∼7269🔥, 0💬
Popular Posts:
How to use the "forward-request" Policy Statement to call the backend service for an Azure API servi...
How To Read a File in Binary Mode in PHP? If you have a file that stores binary data, like an execut...
Can Multiple Paragraphs Be Included in a List Item? Yes. You can include multiple paragraphs in a si...
Where to get the detailed description of the json_encode() Function in PHP? Here is the detailed des...
How to use the urllib.request.Request object to build more complex HTTP request? The urllib.request....