I have a problem with retrieving numbers from an array, For eg, I will have an array like this
[20, 25, 40, 50, 30, 45, 33, 25]
I would like to retrieve the first 3 minimum numbers from the array. Neither too big nor too small and not to be duplicated For eg ouput will be
[20, 25, 30]
You can use like this way
$input = [20, 25, 40, 50, 30, 45, 33, 25 , 20];
$uniq = array_unique($input);
sort($uniq);
return array_slice($uniq, 0, 3);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.