<?php
$arr = [11,18,21,141,811];
$max = $arr[0];
$max_key = 0;
foreach( $arr as $key => $value)
{
if($value > $max)
{
$max = $value;//哪個最大就指派給$max
$max_key = $key;//最大值,索引指派
}
}
echo $max,'索引是:'.$max_key;
轉載于:https://www.cnblogs.com/xm666/p/11191792.html