Skip to content
Advertisement

How to get top 3 Positions (Values) from array in PHP Including Duplicate

I have a sorted array in descending order such as with values 100 , 98, 96, 90 .... and I am using foreach() loop to iterate over the array and use if condition with limit 3 such as `

JavaScript

to get top 3 positions. but the problem is that if there exist two same values such as 100 , 98, 98, 96, 90 . . then limits should increase from 3 to 4 so that on position 2 there exist two values 98, 98 and position 3 contain value 90 instead of 2nd 98 remember that I need both duplicate number on one position such as two students with same marks stands against one position. thanks in advance

Advertisement

Answer

Check the solution for this:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement