/** * Given a State FIPS code and an ending year, returns the (unadjusted) county-level unemployment levels for the previous 10 year period. * Seasonally adjusted data does not appear to be available at the county level. * * @param string stateId * @param string endYear * @return string[] $data */ public static function grabUnadjUnemploymentData($stateId, $endYear) { ini_set('max_execution_time', 0); static::$data = array(); $codes = FipsCodeGenerator::getFipsList($stateId); $index = 0; $tableList = array(); foreach ($codes as $code) { if (count($tableList) >= 25) { $results = static::queryAPI($tableList, $endYear); static::addToData($results); $tableList = array(); } $entry = ''; if (substr($code, -3) == '000') { //the code is a state code $entry .= static::$tablePrefixes['stateUnadjUnemployRate']; $entry .= $code; $entry .= static::$tableSuffixes['stateUnadjUnemployRate']; } else { $entry .= static::$tablePrefixes['countyUnadjUnemployRate']; $entry .= $code; $entry .= static::$tableSuffixes['countyUnadjUnemployRate']; } array_push($tableList, $entry); //appends the entry to the indexed list } $results = static::queryAPI($tableList, $endYear); static::addToData($results); ksort(static::$data); return static::$data; }
private function getFipsString($stateID) { return implode(',', FipsCodeGenerator::getFipsList($stateID)); }