<html>
<?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;i<arr.length;i++){
if(max<arr[i]){
max = arr[i];
index=i;
}
}
return max;
console.log(max);
}
array = [3,9,5];
document.write(test(array));
</script>
</body>
</html>
<?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;i<arr.length;i++){
if(max<arr[i]){
max = arr[i];
index=i;
}
}
return max;
console.log(max);
}
array = [3,9,5];
document.write(test(array));
</script>
</body>
</html>