taranator Posted August 13, 2021 Share Posted August 13, 2021 I need to alter the following code snippet so that the second-greatest value in the array is returned. $dfs = [20727, 20733, 20739, 20746, 20753, 20757]; $dfvs = []; foreach ($dfs as $df) { $dfvs[$df] = utils::get_diary_field_value($case_id, $df); } return max($dfvs); I don't want to break anything and I'm a total noob, so your assistance is very much appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/313548-alter-existing-code-to-return-second-greatest-value-max-function/ Share on other sites More sharing options...
Barand Posted August 13, 2021 Share Posted August 13, 2021 Sort into descending order Get the second element. Quote Link to comment https://forums.phpfreaks.com/topic/313548-alter-existing-code-to-return-second-greatest-value-max-function/#findComment-1589100 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.