Jump to content

+199 previous


newbtophp

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.