Jump to content

[SOLVED] Help!


KI114

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

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.