Re: Validation class method (ssn)
| From: | Tim Gallagher | Date: | Thu, 06 Jun 2002 20:24:58 +0000 |
| Subject: | Re: Validation class method (ssn) | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-6759@lists.php.net to get a copy of this message | ||
Brent,
here is your function (which is really slick) except it sets the values into an array.
-timmyg
$document = implode('', file('http://www.ssa.gov/foia/highgroup.htm'));
$search = array ("'<script[^>]*?>.*?</script>'si", // Strip out javascript
"'<[\/\!]*?[^<>]*?>'si", // Strip out html tags
"'([\r\n])[\s]+'", // Strip out white space
"'&#(\d+);'e"); // evaluate as php
$replace = array ("",
"",
"\\1",
"chr(\\1)");
$text = explode("\n", str_replace ('*','', preg_replace ($search, $replace, $document)));
for ($a = 0; $a < count($text) ; $a++) {
$line = trim($text[$a]);
if ((strlen($line) == 3) && is_numeric($line)) {
$out[$line] = trim($text[$a+1]);
$a++;
}; // end if
}; // end for loop
print_r($out);
At 02:48 PM 6/6/2002 -0500, Brent wrote:
Here is a script to convert the list of high SSN numbers from the SSA website into a PHP array. Well, it actually generates the code for a PHP array, which could be loaded by a validation function very quickly. I'm working on the validator now. <?php$document = implode('', file('http://www.ssa.gov/foia/highgroup.htm'));$search = array ("'<script[^>]*?>.*?</script>'si", // Strip out javascript "'<[\/\!]*?[^<>]*?>'si", // Strip out html tags "'([\r\n])[\s]+'", // Strip out white space "'&#(\d+);'e"); // evaluate as php$replace = array ("", "", "\\1", "chr(\\1)");$text = explode("\n", str_replace ('*','', preg_replace ($search, $replace, $document)));$buffer = '<?php $valid_ssn_list=array('; foreach ($text as $line) { $line = trim($line); if ((strlen($line) == 3) && is_numeric($line)) { $buffer .= "$line=>"; } elseif ((strlen($line) == 2) && is_numeric($line)) { $buffer .= "$line,"; } }$buffer .= '); ?>';print ($buffer);?>