Skip to content

Instantly share code, notes, and snippets.

@sumhat
Last active January 8, 2016 17:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sumhat/32e6afec88a6a9a8b575 to your computer and use it in GitHub Desktop.
Save sumhat/32e6afec88a6a9a8b575 to your computer and use it in GitHub Desktop.
<?php
function s($a) {
return preg_replace('/(?=\d.*\d.*\d.*\d.*\d)(\d)/', '*', $a);
}
echo s('A1BC23D5678'); // A*BC**D5678
echo s('A1BC233D5Df6G78'); // A*BC***D5Df6G78
echo s('A1212B24543C233D5Df6G78dgag'); // A****B*****C***D5Df6G78dgag
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment