Answer the question
In order to leave comments, you need to log in
How to make the numbers in a certain place on the machine be replaced by words?
Hello!
How to implement such a thing:
I have a page - a profile, information from the MySQL database is displayed on it.
There is one stanza - this stanza is the user's rank, info is displayed there in numbers.
Is it possible to implement such a thing that these numbers in the final version on the site page will change into words?
Suppose it displays the number "4" there, and on the page it will show "admin"?
Answer the question
In order to leave comments, you need to log in
Found the solution in the code:
$user_progile[rank] = str_replace("1","Player",$user_progile[rank]);
$user_progile[rank] = str_replace("2","Admin",$user_progile[rank]);
Thanks to everyone who wanted to help
Purely conditions. if, else, elseif... It is also possible through switch case
A more correct and shorter version is map.
$matching = [ 1 => 'admin', 2 => 'editor', 3 => 'user' ];
echo $matching[$role];
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question