pTutorial

New way to learn PHP function

PHP min() Function

Syntax

min($array);

min($variable, $variable [, ...$variable...]);

Parameter Description
Array Array variable

Definition

It Returns the minimum value of an array.

Usage

Min() function is used to find the smallest element of array. If supplied two or more variable, it returns the lowest value argument.

.

Note: Non-numeric strings are evaluated as zero (0) for comparison purposes.

Example of min function

<?php

$no = array(-3, 7, 2);

echo( min($no) );

?>

In above example $no is an array variable that store three integers, pass it to the min function and min function return -3 as a minimum number.

More example of min function

<?php

$no = array(-300, 7, 2,.05,5,0);

echo "Given Array: 
"; var_dump($no); echo "Minimum number of this Array : "; echo( min($no) ); ?>

In above example $no is an array, you can see the structure with the help of var_dump function and after that pass it to the min function which return the minimum number.

max() – Finds the highest value, Works same as min function.

Example

<?php

$no = array(-3, 7, 2);

$a= max($no);

echo $a;

?>

Output

7

QUOTES OF THE DAY

Wonder is the first cause of philosophy.

LIKE ON FACEBOOK

+1 ON GOOGLE

SHARE ON TWITTER