Tuesday, October 21, 2008

Finding the Smallest or Largest Number in an Unordered Series

// define number series
$series = array(76, 7348, 56, 2.6, 189, 67.59, 17594, 2648, 1929.79,↵
54, 329, 820, -1.10, -1.101);

// sort array
sort($series);
// extract maximum/minimum value from sorted array
// result: "Minimum is -1.101 "
$min = $series[0];
echo "Minimum is $min ";

// result: "Maximum is 17594"
$max = $series[sizeof($series)-1];
echo "Maximum is $max";

1 comment:

Ben said...

What a great web blog . I like this blog because of its design and interface. Tutoring near World Equestrian Center Ocala It is user friendly and it is nice to visit the blog.