<?php
header(“Content-type: text/html; charset=utf-8”);
function test($arr){
$maxvalue = $arr[0];
$index = 0;
for($i = 1;$i<count($arr);$i++){
if($maxvalue<$arr[$i]){
$maxvalue = $arr[$i];
$index = $i;
}
}
return $maxvalue;
}
$arr = Array(1,5,3);
$max = test($arr);
echo $max;
?>
<body>
<script type =”text/javascript”>
function test(arr){
var max = arr[0];
var index = 0;
for(var i=1;iif(maxmax = arr[i];
index=i;
}
}
本文来源gaodai.ma#com搞##代!^码@网*
搞gaodaima代码
return max;
console.log(max);
}
array = [3,9,5];
document.write(test(array));
</script>
版权声明:本文为博主原创文章,未经博主允许不得转载。
以上就介绍了php和js中数组中分别循环找出最大的数。,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。