如何找到最大值,返回唯一具有最大值的数字
这是我的代码:
<?php
foreach($graphData as $gt) {
echo $gt['pView'].',';
}
?>
结果:
0,0,0,18,61,106,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
我尝试这样的事情
<?php
$str = '';
foreach ($graphData as $gt){
$str = array($gt['pView'],);}
$max =max($str);
if($max == 0){echo '20';}
else
{echo $max +20;}
?>
结果始终为20,但应为 106 + 20
我的代码有什么问题?