Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $string = readline();
- $countUniqueSymbols = 0;
- $stringCountRepeat = 0;
- $tempString = '';
- $newString = '';
- for ($i = 0; $i < strlen($string); $i++) {
- $currentChar = $string[$i];
- if (is_numeric($currentChar) !== true) {
- $tempString .= $currentChar;
- } else {
- if ($i + 1 < strlen($string)) {
- $nextChar = $string[$i + 1];
- if (is_numeric($nextChar)) {
- $currentChar .= $nextChar;
- }
- }
- $stringCountRepeat = intval($currentChar);
- $newString .= str_repeat(strtoupper($tempString), $stringCountRepeat);
- $tempString = '';
- }
- }
- $rageMessage = array_unique(str_split($newString));
- echo "Unique symbols used: " . count($rageMessage) . PHP_EOL;
- echo $newString;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement