I have an array let say $array = array(2, 1, 8, 3, 6, 0, 10, 10)and I want to get second largest value of that array.
Which sorting/searching technique will be best & how could I use it?
I have an array let say $array = array(2, 1, 8, 3, 6, 0,
Share
I’d just remove the duplicates from your array (using
array_unique) and then usersort(which uses Quicksort) with theSORT_NUMERICflag to sort numerically from highest to lowest:The PHP manual has a comparison of sorting techniques.