在数组PHP中查找最高值的位置

So i want to find the position of the highest number in this array.

$numbers = array($n1, $n2, $n3, $n4, $n5, $n6, $n7, $n8, $n9, $n10);

How do i do that? Thanks

max() can receive an array as a parameter, so with:

$numbers = array($n1, $n2, $n3, $n4, $n5, $n6, $n7, $n8, $n9, $n10);
$max = max($numbers);

$max will have the highest number. Then, use array_search() to get the position:

$pos = array_search($max, $numbers);
echo "Position: ".$pos; // Position: 5

Demo

Note that the position will be the index, so if you want the "real" position, subtract one.