That's actually not going to work if there's more than 1 zero missing. This is better.
if (strlen($zip) < 5) $zip = sprintf('%05d',$zip); else if (strlen($zip) < 10) { $zipArray = explode('-', $zip); $zip = sprintf('%05d',$zipArray[0]); $zip .= "-" . $zipArray[1]; } Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Micah Gersten wrote: > if (strlen($zip) == 4 || strlen($zip) == 9) > $zip = "0$zip"; > > Thank you, > Micah Gersten > onShore Networks > Internal Developer > http://www.onshore.com > > > > Keith Spiller wrote: > >> Hi, >> >> RE: Restore Leading Zeros in Zip Codes >> >> Does anyone happen to have a script that will restore the leading zeros in a >> mixed data set of 5 digit zip codes and 10 digit zip+4 codes? Any >> suggestions? >> >> Thanks, >> >> >> Keith >> >> > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php