Jump to content

Recommended Posts

Why won't this work?!?!?

function findlevel($exp){

$found = false;

$arrayno = 0;

$levels = array(250,500,750,1000,1500,2000,2500,3000,4000,5000,6000,7000,9000);

while($found == false){

if($arrayno == 14){

$level = 13;

}else{

if($exp > $levels["$arrayno"]){

$arrayno += 1;

}else{

$level = $arrayno += 1;

return $level;

$found = true;

}

}

}

}

Link to comment
https://forums.phpfreaks.com/topic/87828-solved-help/
Share on other sites

  function findlevel($exp){

  $found = false;

  $arrayno = 0;

  $levels = array(250,500,750,1000,1500,2000,2500,3000,4000,5000,6000,7000,9000);

  while($found == false){

  if($arrayno == 14){

  $level = 13;

  }else{

  if($exp > $levels[$arrayno]){

  $arrayno += 1;

  }else{

  $level = $arrayno += 1;

  return $level;

  $found = true;

  }

  }

  }

  }

 

 

Link to comment
https://forums.phpfreaks.com/topic/87828-solved-help/#findComment-449354
Share on other sites

At the moment I'm just using it like this

<?
   function findlevel($exp){
      $found = false;
      $arrayno = 0;
      $levels = array(250,500,750,1000,1500,2000,2500,3000,4000,5000,6000,7000,9000);
      while($found == false){
         if($arrayno == 14){
            $level = 13;
         }else{
            if($exp > $levels[$arrayno]){
               $arrayno += 1;
            }else{
               $level = $arrayno += 1;
               return $level;
               $found = true;
            }
         }
      }
   }
   findlevel(1234);
   echo($level);
  ?>

Link to comment
https://forums.phpfreaks.com/topic/87828-solved-help/#findComment-449776
Share on other sites

<?
   function findlevel($exp){
      $found = false;
      $arrayno = 0;
      $levels = array(0,250,500,750,1000,1500,2000,2500,3000,4000,5000,6000,7000,9000);
      $levelc = count($levels);
      $level=0;
      while($level < $levelc && $levels[$level]<$exp) $level++;
      return $level;
   }
   $level=findlevel(1234);
   echo($level);
?>

Link to comment
https://forums.phpfreaks.com/topic/87828-solved-help/#findComment-449785
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.