Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $input = explode("&", readline());
- $pattern = '/[A-Za-z0-9]{16,24}/';
- $keys = [];
- $tempStr = "";
- for ($i = 0; $i < count($input);$i++){
- if (preg_match($pattern, $input[$i])) {
- for ($j = 0; $j < strlen($input[$i]);$j++){
- if (strlen($input[$i]) === 16) {
- $tempStr .= "-" . substr($input[$i], $j, 4);
- $j = $j + 4 - 1;
- } else if (strlen($input[$i]) === 25) {
- $tempStr .= "-" . substr($input[$i], $j, 5);
- $j = $j + 5 - 1;
- }
- }
- $tempStr = ltrim($tempStr, "-");
- for ($n = 0; $n < strlen($tempStr);$n++) {
- if (ctype_digit($tempStr[$n])) {
- $tempStr[$n] = 9 - $tempStr[$n];
- }
- }
- $tempStr = strtoupper($tempStr);
- $keys[] = $tempStr;
- $tempStr = "";
- }
- }
- echo implode(", ", $keys);
Advertisement
Add Comment
Please, Sign In to add comment