note 32535 added to function.min
| From: | calin at php9 dot com | Date: | Fri, 30 May 2003 13:19:39 +0000 |
| Subject: | note 32535 added to function.min | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-49424@lists.php.net to get a copy of this message | ||
if you have an array like this
$arSrc[0]=14;
$arSrc[1]=16;
$arSrc[2]=13;
$arSrc[3]=17;
then in order to get the min element and its position in the array you can do:
$iMinValue = min($arSrc);
$arFlip = array_flip($arSrc);
$iMinPosition = $arFlip[$iMinValue];
echo
'<br />min_value=',
$iMinValue,
'<br />min_position=',
$iMinPosition
;
this example works for also for an associative array; of course with numeric values
----
Manual Page -- http://www.php.net/manual/en/function.min.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+32535
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+32535&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+32535&report=yes