[eluser]esra[/eluser]
Something that I noted down in my journal last May for future reference as cc_help.php but have not used it myself. It was posted on a blog elsewhere but the blog no longer exists. According to my notes, this should result in a mask like xxxx-xxxx-xxxx-1234
Code:
<?php
function mask ( $str, $start = 0, $length = null ) {
$mask = preg_replace ( "/\S/", "*", $str );
if ( is_null ( $length )) {
$mask = substr ( $mask, $start );
$str = substr_replace ( $str, $mask, $start );
} else {
$mask = substr ( $mask, $start, $length );
$str = substr_replace ( $str, $mask, $start, $length );
}
return $str;
}
?>