Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $input = "ATTT";
- $whitelist = "abcdefghijklmnopqrstuvwxyz";
- //Get an array of whitelist characters
- $whitelistLength = strlen($whitelist);
- $i = 0;
- //Assign a slot for each character in a whitelist
- while ($i < $whitelistLength)
- {
- $whitelistArray[$i] = substr($whitelist, $i, 1);
- $i++;
- }
- //Remove the non-whitelist characters from the string
- $inputLength = strlen($input);
- $i = 0;
- //Turn the input string into an array
- while ($i < $inputLength)
- {
- $inputArray[$i] = substr($input, $i, 1);
- $i++;
- }
- print_r($inputArray);
- //If the character isn't in the whitelist array then remove it
- $i = 0;
- foreach ($inputArray as $key => $value)
- {
- foreach ($whitelistArray as $key2 => $value2)
- {
- if (in_array($value, $whitelistArray))
- {
- //Do nothing, check passed
- }
- else
- {
- unset($inputArray[$key]);
- }
- }
- }
- unset($key);
- unset($key2);
- unset($value);
- unset($value2);
- $input = "";
- foreach ($inputArray as $value)
- {
- $input = $input.$value;
- }
- unset($value);
- print_r($whitelistArray);
- echo "\n";
- echo $input;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement