Hello, I'm making a plugin that displays a players kills in a rainbow format behind the player name and the question is How do I separate a 4 digit integer so that I can make a rainbow format? Example: Number: 4000 $player->sendMessage(TextFormat::RED.$number1.TextFormat::ORANGE.$number2.TextFormat::YELLOW.$number3.TextFormat::LIME.$number4); If anyone has a idea, Please let me know. I'm just learning pocketmine so idk Here is a image of what I wanted it to look like:
PHP: $number = 4000;$n_str = (string) $number;$number1 = $n_str[0];$number2 = $n_str[1];$number3 = $n_str[2];$number4 = $n_str[3];
[20:42:36] [Server thread/CRITICAL]: ParseError: "syntax error, unexpected '$number' (T_VARIABLE)" (EXCEPTION) in "plugins/TestPL/src/ItsInspire/TestPL/Main" at line 53