假设我有这个简单的功能
<?php
function levels($theExp) {
if ($theExp < 52) { $theLevel = 2;}
else if ($theExp < 110) { $theLevel = 3;}
else if ($theExp < 175) { $theLevel = 4;}
else if ($theExp < 246) { $theLevel = 5;}
else if ($theExp < 325) { $theLevel = 6;}
else if ($theExp < 413) { $theLevel = 7;}
else if ($theExp < 510) { $theLevel = 8;}
else if ($theExp < 616) { $theLevel = 9;}
else if ($theExp < 734) { $theLevel = 10;}
else if ($theExp < 865) { $theLevel = 11;}
else if ($theExp < 1008) { $theLevel = 12;}
else if ($theExp < 1167) { $theLevel = 13;}
else if ($theExp < 1342) { $theLevel = 14;}
else if ($theExp < 1536) { $theLevel = 15;}
else if ($theExp < 1749) { $theLevel = 16;}
else if ($theExp < 1985) { $theLevel = 17;}
else if ($theExp < 2245) { $theLevel = 18;}
else if ($theExp < 2531) { $theLevel = 19;}
else if ($theExp < 2848) { $theLevel = 20;}
else if ($theExp < 3197) { $theLevel = 21;}
else if ($theExp < 3582) { $theLevel = 22;}
else if ($theExp < 4007) { $theLevel = 23;}
else if ($theExp < 4476) { $theLevel = 24;}
else if ($theExp < 4993) { $theLevel = 25;}
else if ($theExp < 5564) { $theLevel = 26;}
else if ($theExp < 6193) { $theLevel = 27;}
else if ($theExp < 6888) { $theLevel = 28;}
else if ($theExp < 7655) { $theLevel = 29;}
else if ($theExp < 8502) { $theLevel = 30;}
else if ($theExp < 9435) { $theLevel = 31;}
else if ($theExp < 10466) { $theLevel = 32;}
else if ($theExp < 11603) { $theLevel = 33;}
else if ($theExp < 12858) { $theLevel = 34;}
else if ($theExp < 14243) { $theLevel = 35;}
else if ($theExp < 15772) { $theLevel = 36;}
else if ($theExp < 17459) { $theLevel = 37;}
else if ($theExp < 19321) { $theLevel = 38;}
else if ($theExp < 21376) { $theLevel = 39;}
else if ($theExp < 23644) { $theLevel = 40;}
else if ($theExp < 26148) { $theLevel = 41;}
else if ($theExp < 28912) { $theLevel = 42;}
else if ($theExp < 31962) { $theLevel = 43;}
else if ($theExp < 35329) { $theLevel = 44;}
else if ($theExp < 39046) { $theLevel = 45;}
else if ($theExp < 43149) { $theLevel = 46;}
else if ($theExp < 47677) { $theLevel = 47;}
else if ($theExp < 52677) { $theLevel = 48;}
else if ($theExp < 58195) { $theLevel = 49;}
else if ($theExp < 64288) { $theLevel = 50;}
else if ($theExp < 71013) { $theLevel = 51;}
else if ($theExp < 78437) { $theLevel = 52;}
else if ($theExp < 86633) { $theLevel = 53;}
else if ($theExp < 95681) { $theLevel = 54;}
else if ($theExp < 105670) { $theLevel = 55;}
else if ($theExp < 116697) { $theLevel = 56;}
else if ($theExp < 128871) { $theLevel = 57;}
else if ($theExp < 142311) { $theLevel = 58;}
else if ($theExp < 157148) { $theLevel = 59;}
else if ($theExp < 173529) { $theLevel = 60;}
else if ($theExp < 191614) { $theLevel = 61;}
else if ($theExp < 211579) { $theLevel = 62;}
else if ($theExp < 233622) { $theLevel = 63;}
else if ($theExp < 257958) { $theLevel = 64;}
else if ($theExp < 284825) { $theLevel = 65;}
else if ($theExp < 314487) { $theLevel = 66;}
else if ($theExp < 347236) { $theLevel = 67;}
else if ($theExp < 383392) { $theLevel = 68;}
else if ($theExp < 423310) { $theLevel = 69;}
else if ($theExp < 467382) { $theLevel = 70;}
else if ($theExp < 516039) { $theLevel = 71;}
else if ($theExp < 569760) { $theLevel = 72;}
else if ($theExp < 629070) { $theLevel = 73;}
else if ($theExp < 694553) { $theLevel = 74;}
else if ($theExp < 766850) { $theLevel = 75;}
else if ($theExp < 846671) { $theLevel = 76;}
else if ($theExp < 934799) { $theLevel = 77;}
else if ($theExp < 1032098) { $theLevel = 78;}
else if ($theExp < 1139523) { $theLevel = 79;}
else if ($theExp < 1258129) { $theLevel = 80;}
else if ($theExp < 1389078) { $theLevel = 81;}
else if ($theExp < 1533655) { $theLevel = 82;}
else if ($theExp < 1693280) { $theLevel = 83;}
else if ($theExp < 1869518) { $theLevel = 84;}
else if ($theExp < 2064099) { $theLevel = 85;}
else if ($theExp < 2278932) { $theLevel = 86;}
else if ($theExp < 2516125) { $theLevel = 87;}
else if ($theExp < 2778005) { $theLevel = 88;}
else if ($theExp < 3067142) { $theLevel = 89;}
else if ($theExp < 3386373) { $theLevel = 90;}
else if ($theExp < 3738830) { $theLevel = 91;}
else if ($theExp < 4127973) { $theLevel = 92;}
else if ($theExp < 4557619) { $theLevel = 93;}
else if ($theExp < 5031985) { $theLevel = 94;}
else if ($theExp < 5555725) { $theLevel = 95;}
else if ($theExp < 6133979) { $theLevel = 96;}
else if ($theExp < 6772421) { $theLevel = 97;}
else if ($theExp < 7477315) { $theLevel = 98;}
elseif ($theExp < 8255580) { $theLevel = 99;}
return $theLevel;
}
?>
你输入你的经验,它会给你你的等级。这两个数字是从 MySQL 数据库中提取的......
所以,假设我们有$level
和$exp
。
$level
鉴于我的 is1
和$exp
is ,我将如何找到剩下的经验以达到下一个级别0
?