获取PHP数组中的最低值和最高值不会向我显示正确的数字

I have the following array:

Array
(
    [0] => 124,95
    [1] => 139,95
    [2] => 149,95
    [3] => 1200
    [4] => 150
    [5] => 154,95
    [6] => 130
    [7] => 189,95
    [8] => 199,95
    [9] => 30
    [10] => 150
)

And I am trying to get the lowest (30) and highest (1200) numbers from it.

So I did this:

while($getpricesproducts = $getpricesproductscon->fetch_assoc()){
  $prijsarray[] = $getpricesproducts['prijs'];
}

// Lowest and highest price to put in price slider
$prijslow = min($prijsarray);
$prijshigh = max($prijsarray);

echo $prijslow;

echo $prijshigh;

$prijsarray is above array.

But the echoed values are 30 as min number and 150 as max. Why is that? Does it have something to do with the commas in some numbers? Still it is weird that 1200 is not the max number since it does not have any commas.

You can use array_map with strtr to convert all the numbers in your array from their current format to floating point. Then you can take the min and max and use number_format to convert them back to your format:

$new_array = array_map(function ($v) { return (float)strtr($v, array(',' => '.', '.' => '')); }, $array);
echo number_format(min($new_array), 2, ',', '.') . "
";
echo number_format(max($new_array), 2, ',', '.') . "
";

Output:

30,00
1.200,00

Demo on 3v4l.org

You can fix your code as below:

while($getpricesproducts = $getpricesproductscon->fetch_assoc()){
    $prijsarray[] = (float) str_replace(',', '.', $getpricesproducts['prijs']);
}

But as other commented, it would be better if you fix your database to store prices as floating numbers.

As said in max function documentation:

Values of different types will be compared using the standard comparison rules. For instance, a non-numeric string will be compared to an integer as though it were 0, but multiple non-numeric string values will be compared alphanumerically. The actual value returned will be of the original type with no conversion applied.

So, you could try to convert all values to float before inserting to your array:

while($getpricesproducts = $getpricesproductscon->fetch_assoc()){
  $prijsarray[] = floatval(str_replace(',', '.', $getpricesproducts['prijs'])); 
}

// Lowest and highest price to put in price slider
$prijslow = min($prijsarray);
$prijshigh = max($prijsarray);

echo $prijslow;

echo $prijshigh;