newbtophp Posted August 13, 2010 Share Posted August 13, 2010 I'm trying to create a function where you specify the $points it will then do some mathematical stuff with the $points (explain later) an return an array containing the $rank and $level. The mathematical stuff: It starts at 99 and when it reaches +199 it changes the key of the array. I'm not sure how to describe this theirfore i'll just provide examples: Example 1: If $points <= 99 It will return an array containing $ranks[0] and $levels[0], would be the following: return array('Peon', 0); Example 2: If $points >= 100 && $points <= 299 It will return an array containing $ranks[1] and $levels[1], would be the following: return array('Grunt', 1); Example 3: If $points >= 300 && $points <= 499 It will return an array containing $ranks[2] and $levels[2], would be the following: return array('Berserker', 2); etc.. until it reaches the 7th key of the $ranks/$levels array Heres my code: <?php function rank($points){ //their are 0-7 levels $levels = range(0, 7); //7 ranks $ranks = array('Peon', 'Grunt', 'Berserker', 'Tauren', 'Spirit Walker', 'Wind Rider'); for(...) { return array($rank, $level); } } ?> Link to comment https://forums.phpfreaks.com/topic/210640-199-previous/ Share on other sites More sharing options...
Adam Posted August 13, 2010 Share Posted August 13, 2010 .. and your question? Link to comment https://forums.phpfreaks.com/topic/210640-199-previous/#findComment-1098844 Share on other sites More sharing options...
newbtophp Posted August 13, 2010 Author Share Posted August 13, 2010 Never mind solved it using if statements Link to comment https://forums.phpfreaks.com/topic/210640-199-previous/#findComment-1098845 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.