/ Published in: PHP
URL: http://reusablecode.blogspot.com/2009/04/social-security-numbers.html
Format and validate social security numbers. Be aware of the legal issues surrounding the collection of these private numbers.
Expand |
Embed | Plain Text
<?php /* PHP Library - Social Security Number-related functions Copyright (c) 2009, reusablecode.blogspot.com; some rights reserved. This work is licensed under the Creative Commons Attribution License. To view a copy of this license, visit http://creativecommons.org/licenses/by/3.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA. */ // Format a Social Security Number. function formatSSN($ssn) { { } else { } } // Validate a Social Security Number. function isValidSSN($ssn) { /* None of the digit groups can be all zeros. Area number 666 is unassigned. Numbers from 987-65-4320 to 987-65-4329 are reserved for use in advertisements. Many SSNs have been invalidated by use in advertising. */ if (eregi("^((000|666)\-?\d{2}\-?\d{4}|\d{3}\-?00\-?\d{4}|\d{3}\-?\d{2}\-?0000|987\-?65\-?432\d{1}|042\-?10\-?3580|062\-?36\-?0749|078\-?05\-?1120|095\-?07\-?3645|128\-?03\-?6045|135\-?01\-?6629|141\-?18\-?6941|165\-?(16|18|20|22|24)\-?7999|189\-?09\-?2294|212\-?09\-?(7694|9999|219\-?09\-?9999|306\-?30\-?2348|308\-?12\-?5070|468\-?28\-?8779|549\-?24\-?1889)$", $ssn) { $result = false; } // Numbers above 772 are currently unassigned. { $result = false; } return $result; } ?>
You need to login to post a comment.
