Home > Backend Development > PHP Tutorial > Loop through the arrays in php and js to find the largest number.

Loop through the arrays in php and js to find the largest number.

WBOY
Release: 2016-08-08 09:20:55
Original
892 people have browsed it


header("Content-type: text/html; charset=utf-8");
   function test($arr){
$maxvalue = $arr[0];
$index = 0;
for($i = 1;$iif($maxvalue<$arr[$i]){
$maxvalue = $arr[$i];
$index = $i;
}

}
return $maxvalue;
   }
   $arr = Array(1,5,3);
$max = test($arr);
echo $max;
?>

 
 

版权声明:本文为博主原创文章,未经博主允许不得转载。

以上就介绍了php和js中数组中分别循环找出最大的数。,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template