Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.