获取while循环php中的最低值



我有这个问题。这应该很容易,但我被难住了,我已经看了,但我还没有找到答案。我会尽可能地描述它。这是我的代码的缩写:

<?php
$myArray = [$a, $b, $c, $d, $e, $f];
$arrayLength = count($myArray);

$i = 0; 
while ($i < $arrayLength)
{
//Code that displays lowest value in array;
//echo $myArray[$i] ."<br />";
$i++;
}
?>

我的问题是:假设,$a,$b,$c,$d,$e,$f是用户输入的变量,并且都是整数,我如何在这个while循环中回显数组中的最低值?谢谢!

$start的原始值保存在另一个变量中,以便在循环中回显它。

$lowest_start = $start;
while ($start <= $stop){
echo "$lowest_start $start<br>n";
$start++;
}

我们通常也使用for循环而不是while循环:

for ($i = $start; $i <= $stop; $i++) {
echo "$start $i<br>n";
}

最新更新