Skip to content

Commit 7d55694

Browse files
committed
added format_ssn
1 parent fd44cdd commit 7d55694

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/Util.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -898,6 +898,16 @@ public static function format_phone($input) {
898898
return $input;
899899
}
900900

901+
public static function format_ssn($input) {
902+
$clean_input = substr(preg_replace('/\D+/i', '', $input), -9);
903+
if (preg_match('/^(\d{3})(\d{2})(\d{4})$/', $clean_input, $matches)) {
904+
$result = $matches[1].'-'.$matches[2].'-'.$matches[3];
905+
return $result;
906+
}
907+
908+
return $input;
909+
}
910+
901911
/**
902912
* Obtain a brand constant from a PAN
903913
* https://stackoverflow.com/a/21617574/3685987

0 commit comments

Comments
 (0)