0
It would be possible to minimize or make a function that has the same functioning of this code below?
if($rank <= 50){
echo 'Descolorido';
}
else if($rank <= 100){
echo 'Azul Bebê';
}
else if($rank <= 200){
echo 'Roxo Bacon';
}
else if($rank <= 300){
echo 'Verde ET';
}
else if($rank <= 500){
echo 'Marrom Madeira';
}
else if($rank <= 700){
echo 'Laranja Power';
}
else if($rank <= 900){
echo 'Vermelho Killer';
}
else if($rank <= 1500){
echo 'Rosa Piriguete';
}
else if($rank <= 1700){
echo 'Amarelo Bobba';
}
else if($rank <= 2000){
echo 'Turquesa Maravilha';
}
else if($rank <= 2300){
echo 'Gótica Má';
}
else if($rank <= 2500){
echo 'Ametista Destruidor';
}
else if($rank <= 2700){
echo 'Esmeralda Divindade';
}
else if($rank <= 3000){
echo 'Púrpura Star';
}
else if($rank <= 3500){
echo 'Dourado Rei';
}
else if($rank >= 3500){
echo 'Rainbow';
}
I didn’t quite understand how to display the rank with a certain amount of messages.
– Paulo Sérgio Filho
I think you got it a little wrong. The function is based on for example: determineRank($quantityand messages) and will display the Tarja equivalent to that amount. For example: <= 50 is Discolored would look like this in theory (I suppose I have 45 messages): determineRank(45) and display Discolored, because 45 is less than 50 (<=)
– Paulo Sérgio Filho
I believe his code should be
determineRank($input)
and so does exactly what you need.– Woss
Thanks @Andersoncarloswoss. Rand() was going to generate a random value every time, so it wasn’t beating :)
– gmsantos
@Paulosérgiofilho corrected the example. The logic is correct, only the example that was wrong
– gmsantos
I got it, thank you very much!
– Paulo Sérgio Filho
I had tried before to use the function directly as @Andersoncarloswoss said, but it had not worked. Probably had done something wrong! :)
– Paulo Sérgio Filho