+ 3

How can i find a first largest value from array, the second largest value from array, and third largerst value from array

21st Jan 2018, 7:46 AM
Rahmad Hidayat
Rahmad Hidayat - avatar
5 Respuestas
+ 3
Arrange the array in descending order and pick index 0,1,2!!
21st Jan 2018, 7:51 AM
Ayush Tripathi
+ 23
i was coming to say the same @Ayush 😂
21st Jan 2018, 8:00 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 2
just loop over it and keep the first to third highest value
21st Jan 2018, 8:24 AM
Jeremy
Jeremy - avatar
+ 1
sorry i newbie. thanks for help me !
21st Jan 2018, 12:02 PM
Rahmad Hidayat
Rahmad Hidayat - avatar
0
<?php $numbers=array(4,6,2,22,11); sort($numbers); echo $numbers; ?> I think you can use rsort as well to reverse the order of the numbers https://www.w3schools.com/php/func_array_sort.asp http://php.net/manual/en/function.sort.php Php.net/manual is a good resource for all things php and w3 schools is an all around good resource for almost everything Hope it helps.
21st Jan 2018, 9:09 AM
Tarantino
Tarantino - avatar