How to find minimum of 3 numbers in an array?

there is an array of 5 to 10 digits, maybe more, have to find minimum of 3 numbers, you know how to find 2, but how to find 3 something can not come up
April 4th 20 at 00:41
2 answers
April 4th 20 at 00:43
Solution
sort($array);
array_slice($array, 0, 3);
https://ideone.com/u0PqT2
We need to work in pairs: you - code, I - algorithm))) - Wava.Gerho commented on April 4th 20 at 00:46
@Wava.Gerho, )) - carole commented on April 4th 20 at 00:49
@carole, to be fair, still use the built in feature of sorts one can, and to make the algorithm more difficult. - green_Grant commented on April 4th 20 at 00:52
April 4th 20 at 00:45
Solution
Sort the array elements and taking the first 3 minimal elements.

Find more questions by tags PHP