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, ∼7371🔥, 0💬
Popular Posts:
FYIcenter JSON Validator and Formatter is an online tool that checks for syntax errors of JSON text ...
How to use the JSON to XML Conversion Tool at freeformatter.com? If you want to try the JSON to XML ...
What is EPUB 2.0 Metadata "dc:publisher" and "dc:rights" elements? EPUB 2.0 Metadata "dc:publisher" ...
How to access Query String parameters from "context.Request.Url.Que ry"object in Azure API Policy? Q...
How to add request body examples to my Azure API operation to make it more user friendly? If you hav...