PHP else if into arrays?
<p>OK, let's say I have this small snippit of a bunch of else-ifs in PHP</p>

<pre><code>function getLevelByExp($theExp) {

    if ($theExp &lt; 83) { $theLevel = 1; }
else if ($theExp &lt; 175) { $theLevel = 2; }
else if ($theExp &lt; 278) { $theLevel = 3; }
else if ($theExp &lt; 392) { $theLevel = 4; }
else if ($theExp &lt; 519) { $theLevel = 5; }
else if ($theExp &lt; 659) { $theLevel = 6; }
else if ($theExp &lt; 814) { $theLevel = 7; }
else if ($theExp &lt; 987) { $theLevel = 8; }
else if ($theExp &lt; 1178) { $theLevel = 9; }
else if ($theExp &lt; 1390) { $theLevel = 10; }
else if ($theExp &lt; 1624) { $theLevel = 11; }
else if ($theExp &lt; 1884) { $theLevel = 12; }
else if ($theExp &lt; 2172) { $theLevel = 13; }
else if ($theExp &lt; 2492) { $theLevel = 14; }
else if ($theExp &lt; 2845) { $theLevel = 15; }
else if ($theExp &lt; 3237) { $theLevel = 16; }
else if ($theExp &lt; 3671) { $theLevel = 17; }
else if ($theExp &lt; 4151) { $theLevel = 18; }
else if ($theExp &lt; 4683) { $theLevel = 19; }
else if ($theExp &lt; 5273) { $theLevel = 20; }
else if ($theExp &lt; 5926) { $theLevel = 21; }
else if ($theExp &lt; 6650) { $theLevel = 22; }
else if ($theExp &lt; 7451) { $theLevel = 23; }
else if ($theExp &lt; 8339) { $theLevel = 24; }
else if ($theExp &lt; 9322) { $theLevel = 25; }
else if ($theExp &lt; 10412) { $theLevel = 26; }
else if ($theExp &lt; 11618) { $theLevel = 27; }
else if ($theExp &lt; 12955) { $theLevel = 28; }
else if ($theExp &lt; 14436) { $theLevel = 29; }
else if ($theExp &lt; 16076) { $theLevel = 30; }
else if ($theExp &lt; 17893) { $theLevel = 31; }
else if ($theExp &lt; 19906) { $theLevel = 32; }
else if ($theExp &lt; 22137) { $theLevel = 33; }
else if ($theExp &lt; 24607) { $theLevel = 34; }
else if ($theExp &lt; 27345) { $theLevel = 35; }
else if ($theExp &lt; 30377) { $theLevel = 36; }
else if ($theExp &lt; 33737) { $theLevel = 37; }
else if ($theExp &lt; 37460) { $theLevel = 38; }
else if ($theExp &lt; 41584) { $theLevel = 39; }
else if ($theExp &lt; 46154) { $theLevel = 40; }
else if ($theExp &lt; 51217) { $theLevel = 41; }
else if ($theExp &lt; 56827) { $theLevel = 42; }
else if ($theExp &lt; 63042) { $theLevel = 43; }
else if ($theExp &lt; 69929) { $theLevel = 44; }
else if ($theExp &lt; 77560) { $theLevel = 45; }
else if ($theExp &lt; 86015) { $theLevel = 46; }
else if ($theExp &lt; 95383) { $theLevel = 47; }
else if ($theExp &lt; 105764) { $theLevel = 48; }
else if ($theExp &lt; 117266) { $theLevel = 49; }
else if ($theExp &lt; 130010) { $theLevel = 50; }
else if ($theExp &lt; 144132) { $theLevel = 51; }
else if ($theExp &lt; 159781) { $theLevel = 52; }
else if ($theExp &lt; 177120) { $theLevel = 53; }
else if ($theExp &lt; 196333) { $theLevel = 54; }
else if ($theExp &lt; 217623) { $theLevel = 55; }
else if ($theExp &lt; 241215) { $theLevel = 56; }
else if ($theExp &lt; 267356) { $theLevel = 57; }
else if ($theExp &lt; 296323) { $theLevel = 58; }
else if ($theExp &lt; 328421) { $theLevel = 59; }
else if ($theExp &lt; 363990) { $theLevel = 60; }
else if ($theExp &lt; 403404) { $theLevel = 61; }
else if ($theExp &lt; 447078) { $theLevel = 62; }
else if ($theExp &lt; 495475) { $theLevel = 63; }
else if ($theExp &lt; 549104) { $theLevel = 64; }
else if ($theExp &lt; 608531) { $theLevel = 65; }
else if ($theExp &lt; 674384) { $theLevel = 66; }
else if ($theExp &lt; 747357) { $theLevel = 67; }
else if ($theExp &lt; 828220) { $theLevel = 68; }
else if ($theExp &lt; 917826) { $theLevel = 69; }
else if ($theExp &lt; 1017122) { $theLevel = 70; }
else if ($theExp &lt; 1127154) { $theLevel = 71; }
else if ($theExp &lt; 1249084) { $theLevel = 72; }
else if ($theExp &lt; 1384199) { $theLevel = 73; }
else if ($theExp &lt; 1533925) { $theLevel = 74; }
else if ($theExp &lt; 1699840) { $theLevel = 75; }
else if ($theExp &lt; 1883698) { $theLevel = 76; }
else if ($theExp &lt; 2087436) { $theLevel = 77; }
else if ($theExp &lt; 2313207) { $theLevel = 78; }
else if ($theExp &lt; 2563392) { $theLevel = 79; }
else if ($theExp &lt; 2840632) { $theLevel = 80; }
else if ($theExp &lt; 3147852) { $theLevel = 81; }
else if ($theExp &lt; 3488295) { $theLevel = 82; }
else if ($theExp &lt; 3865553) { $theLevel = 83; }
else if ($theExp &lt; 4283609) { $theLevel = 84; }
else if ($theExp &lt; 4746873) { $theLevel = 85; }
else if ($theExp &lt; 5260236) { $theLevel = 86; }
else if ($theExp &lt; 5829115) { $theLevel = 87; }
else if ($theExp &lt; 6459514) { $theLevel = 88; }
else if ($theExp &lt; 7158087) { $theLevel = 89; }
else if ($theExp &lt; 7932204) { $theLevel = 90; }
else if ($theExp &lt; 8790038) { $theLevel = 91; }
else if ($theExp &lt; 9740641) { $theLevel = 92; }
else if ($theExp &lt; 10794045) { $theLevel = 93; }
else if ($theExp &lt; 11961369) { $theLevel = 94; }
else if ($theExp &lt; 13254932) { $theLevel = 95; }
else if ($theExp &lt; 14688387) { $theLevel = 96; }
else if ($theExp &lt; 16276862) { $theLevel = 97; }
else if ($theExp &lt; 18037122) { $theLevel = 98; }
else if ($theExp &lt; 20000000) { $theLevel = 99; }
else { $theLevel = 99; }

return $theLevel;

}
</code></pre>

<p>As you can tell, I can easily get the Level, using the experience points, like <code>$currentLevel = getLevelByExp(300)</code> which would output: <code>3</code>.</p>

<p>However, would I make it so it's reversed? Get the EXPERIENCE by Level so if I enter <code>getExpByLevel(3)</code> it would output: <code>392</code>?</p>
