getting top and bottom numbers
Moderator: General Moderators
-
mccommunity
- Forum Commoner
- Posts: 62
- Joined: Mon Oct 07, 2002 8:55 am
getting top and bottom numbers
Is there a function in that will grab the top number out of and array and the bottom number?
like LBound and UBound in visial basic? Not that I know of.
But you might take the array keys, sort them and use the first and the last entry
But you might take the array keys, sort them and use the first and the last entry
Code: Select all
<?php
$arr = array(
9=>'i',
5=>'e',
25=>'y',
12=>'l'
);
$keys = array_keys($arr);
sort($keys);
echo $keys[0], '...', $keys[count($keys)-1];
?>If the array isn't multidimensional, but just simple like
array(1,4,6,3,4,8) you can do
array(1,4,6,3,4,8) you can do
Code: Select all
$foo = array(7,4,9,2,4,3,1);
echo min($foo);
echo max($foo);