Finding the smallest value in an Array

$myArray = array(48, 9, 52, 183);

I have $myArray like the above.

I like to find the smallest value in the Array.

So I made the code below.

[b]code[/b]

if ( $myArray[0] < $myArray[1] ) {
$smallest_between01=$myArray[0];
} else {
$smallest_between01=$myArray[1];
}


if ( $myArray[2] < $myArray[3] ) {
$smallest_between23=$myArray[2];
} else {
$smallest_between23=$myArray[3];
}



if ( $smallest_between01 < $smallest_between23 ) {
$smallest=$smallest_between01;
} else {
$smallest=$smallest_between23;
}

echo $smallest;


[b]result[/b]

9

I now found the smallest value “9” which I wanted.

I guess there might be more fine code for finding the smallest value in the Array.

Do you have any?

( I am a beginner at Array.)

http://www.php.net/manual/en/function.sort.php

See min function: http://www.php.net/manual/en/function.min.php