<?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;

 

相关文章:

  • 2021-12-18
  • 2022-12-23
  • 2022-12-23
  • 2022-02-22
  • 2022-12-23
  • 2022-02-24
  • 2021-07-25
  • 2021-05-04
猜你喜欢
  • 2021-06-08
  • 2022-12-23
  • 2022-12-23
  • 2022-01-18
  • 2022-03-07
  • 2022-01-20
  • 2021-12-27
相关资源
相似解决方案