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.
Â
⇒PHP Built-in Functions for Arrays
⇒⇒PHP Tutorials
2016-12-28, 1928👍, 0💬
Popular Posts:
How to add request URL Template Parameters to my Azure API operation 2017 version to make it more us...
How to create a new API on the Publisher Dashboard of an Azure API Management Service? If you are ne...
How to extend json.JSONEncoder class? I want to encode other Python data types to JSON. If you encod...
How to read RSS validation errors at w3.org? If your RSS feed has errors, the RSS validator at w3.or...
How to use "link" command tool to link objet files? If you have object files previously compiled by ...