Gibbs Posted October 27, 2007 Share Posted October 27, 2007 I'm trying to find the two largest values in an array. The max function is great but I'm also looking for the second largest number... I can't use any sorting functions as the array name must stay the same. The sort functions I've tried, for example, will rename $array["TEST1"] to $array[0]. Any help appreciated. Thanks. Quote Link to comment Share on other sites More sharing options...
unidox Posted October 27, 2007 Share Posted October 27, 2007 In the query just use ASC/DESC and then pick out the last/first 2 numbers. Quote Link to comment Share on other sites More sharing options...
Barand Posted October 27, 2007 Share Posted October 27, 2007 use asort() to preserve keys Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.