Is there a way to blank / x' out the middle (keep first and last two) digits / letters of a word or number ?
Example:
123456789 would be 12XXXXX89 or Iamaword = Iaxxxxrd
Is there a way to blank / x' out the middle (keep first and last two) digits / letters of a word or number ?
Example:
123456789 would be 12XXXXX89 or Iamaword = Iaxxxxrd
I wasn't sure if the uppercase or lowercase Xs were necessary, so the first line could be removed for simplicity:
$chr = ctype_digit($str) ? 'X' : 'x'; // big X for numbers, x for letters
$new_str = substr($str, 0, 2) . str_repeat($chr, strlen($str) - 4) . substr($str, -2);