您好,欢迎访问一九零五行业门户网

php如何求数组中的最大值

这次给大家跟大家聊聊在php中如何求数组中的最大值,下面就是实战案例,一起来看一下。
话不多说,直接上代码:
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=gbk" /> <title>php求数组中最大值</title> <style type="text/css"> table{ width: 980px; border:#000 solid 1px; margin: auto; } td{ border:#000 solid 1px; } </style> </head> <body> <?php //求数组中的最大值 $num=array(10,20,35,50,45,32,18); $max=$num[0]; for($i=1;$i<count($num);$i++){ if($num[$i]>$max){ $max=$num[$i]; } } echo '数组中最大的数为:'.$max; ?> </body> </html>
相关推荐:
php里获取一维数组里的最大值和最小值
php 获取数组值中最大的数据
如何求数组中的最大值
以上就是php如何求数组中的最大值的详细内容。
其它类似信息

推荐信息