Judge the level based on user points
<code>lv1:1~50 lv2:51~110 lv3:111~180 lv4:181~260 ...... 依次类推直到lv100</code>
How to quickly and efficiently determine the level based on the user’s points? It's okay to judge a few pieces of data if if, but if there are 100 ifs, the efficiency will drop. Does anyone have any good methods?
Judge the level based on user points
<code>lv1:1~50 lv2:51~110 lv3:111~180 lv4:181~260 ...... 依次类推直到lv100</code>
How to quickly and efficiently determine the level based on the user’s points? It's okay to judge a few pieces of data if if, but if there are 100 ifs, the efficiency will drop. Does anyone have any good methods?
Thank you very much to see that everyone is very active in helping me solve this problem. This column is called "Write Answers", which is not actually an answer, it just meets my needs.
This solution is actually to judge the user's level based on the user's online time, and upgrade to a certain level after meeting a certain length of time. Later, it was decided to use this method to judge the user's level time: the square of the current level is the next level. The number of hours required.
Finally, find the user level based on the duration
(int)sqrt($onlinetime)+1;