Its values are strings, so the result you get is the minimum of an alphabetic ordering, which would be even the 111,5.
To get the minimum in numerical terms you have to convert each value into number. But in your case you still have the detail of , which will not be interpreted as decimal separator, and which can be bypassed by replacing , for . through function str_replace.
The iteration over each element of the array to make the conversion can be done with array_map, that gets shorter and more direct.
Example:
$arr = Array("111,5", "81", "90,8", "79,6", "6");
$arrNumeros = array_map(function($el){
return floatval(str_replace(',', '.', $el));
}, $arr);
echo min($arrNumeros); // 6
See this example in Ideone
To make clear the difference between the two arrays, see the result of var_dump($arrNumeros);:
array(5) {
[0]=>
float(111.5)
[1]=>
float(81)
[2]=>
float(90.8)
[3]=>
float(79.6)
[4]=>
float(6)
}
Enter the code you tested. Note that php only considers the number until the comma and what comes after is ignored.
– rray
Its values are strings soon
minfinds the smallest alphabetically, which is the111,5– Isac
@Isac I would have to convert the string into another format?
– Leandro Marzullo
Yes, for a numerical type, since it wants to compare them numerically.
– Woss