I'm trying to make a switch
in PHP, but it returns me some very strange values.
For example, if the variable $xp
is equal to 0
, it returns me that the level is 20
.
I'm not understanding '-'
switch($xp){
case($xp <= 60);
$nivel = 0;
break;
case($xp <= 200);
$nivel = 1;
break;
case($xp <= 350);
$nivel = 2;
break;
//... vários case dps.
case($xp <= 4375);
$nivel = 18;
break;
case($xp <= 5000);
$nivel = 19;
break;
// se $xp for igual a 0 ele me retorna $nivel = 20
case($xp > 5000);
$nivel = 20;
break;
}
$xp
is returned from the database, it is INT
.