Re: [PHP] Restore Leading Zeros in Zip Codes

2008-08-25 Thread Philip Thompson
On Aug 21, 2008, at 9:44 PM, 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 Of course as other

Re: [PHP] Restore Leading Zeros in Zip Codes

2008-08-24 Thread tedd
At 7:47 PM +0100 8/24/08, ioannes wrote: George Bernard Shaw, an Irishman. tedd wrote: As Churchill once said "We are two peoples separated by a common language." And so did Oscar Wilde, Mark Twain, and Patton -- Google it and you'll find that everyone said it. Cheers, tedd -- --

Re: [PHP] Restore Leading Zeros in Zip Codes

2008-08-24 Thread ioannes
George Bernard Shaw, an Irishman. tedd wrote: At 11:13 PM +0100 8/22/08, Ashley Sheridan wrote: Not to mention, but of the two major English speaking countries, both America and England have different address standards. All too often an American site seems to think that a postcode is the sam

Re: [PHP] Restore Leading Zeros in Zip Codes

2008-08-23 Thread tedd
At 11:13 PM +0100 8/22/08, Ashley Sheridan wrote: Not to mention, but of the two major English speaking countries, both America and England have different address standards. All too often an American site seems to think that a postcode is the same thing as a zip code, and then rejects it in a

Re: [PHP] Restore Leading Zeros in Zip Codes

2008-08-22 Thread Ashley Sheridan
On Fri, 2008-08-22 at 17:16 -0400, tedd wrote: > At 12:35 PM -0400 8/22/08, Dan Joseph wrote: > > > tedd wrote: > > > > >> Why take them out in the first place? Keep the zip code as a string. > > After > > >> all, not all countries use just numbers. > > > > > >From a recent experience, you sho

Re: [PHP] Restore Leading Zeros in Zip Codes

2008-08-22 Thread tedd
At 12:35 PM -0400 8/22/08, Dan Joseph wrote: > tedd wrote: >> Why take them out in the first place? Keep the zip code as a string. After >> all, not all countries use just numbers. From a recent experience, you should all listen to Tedd's advice. I inhereited an application when I came to

Re: [PHP] Restore Leading Zeros in Zip Codes

2008-08-22 Thread Andrew Ballard
On Fri, Aug 22, 2008 at 12:28 PM, Afan Pasalic <[EMAIL PROTECTED]> wrote: > > > tedd wrote: >> >> At 8:44 PM -0600 8/21/08, 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

Re: [PHP] Restore Leading Zeros in Zip Codes

2008-08-22 Thread Dan Joseph
On Fri, Aug 22, 2008 at 12:28 PM, Afan Pasalic <[EMAIL PROTECTED]> wrote: > > > tedd wrote: > >> At 8:44 PM -0600 8/21/08, 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

Re: [PHP] Restore Leading Zeros in Zip Codes

2008-08-22 Thread Afan Pasalic
tedd wrote: At 8:44 PM -0600 8/21/08, 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 Keith: Why

Re: [PHP] Restore Leading Zeros in Zip Codes

2008-08-22 Thread tedd
At 8:44 PM -0600 8/21/08, 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 Keith: Why take them out

RE: [PHP] Restore Leading Zeros in Zip Codes

2008-08-21 Thread Warren Vail
ren Vail'; 'Keith Spiller'; php-general@lists.php.net > Subject: RE: [PHP] Restore Leading Zeros in Zip Codes > > Dave brought up something I forgot, what if the "-" is > already in the sip code; > > Modify the code as follows; > > I

RE: [PHP] Restore Leading Zeros in Zip Codes

2008-08-21 Thread Warren Vail
$zipcode = substr($zipcode,0,5)."-".substr(zipcode,5); } > -Original Message- > From: Warren Vail [mailto:[EMAIL PROTECTED] > Sent: Thursday, August 21, 2008 8:08 PM > To: 'Keith Spiller'; php-general@lists.php.net > Subject: RE: [PHP] Restore Leading

RE: [PHP] Restore Leading Zeros in Zip Codes

2008-08-21 Thread Warren Vail
I'd try something like; If(strlen($zipcode) <= 5) $zipcode = sprintf("%05d",$zipcode); Else { $zipcode = sprintf("%09d",$zipcode); $zipcode = substr($zipcode,0,5)."-".substr(zipcode,5); } This isn't real elegant, but it should do the trick. You may notice that the 10 character zip code i

Re: [PHP] Restore Leading Zeros in Zip Codes

2008-08-21 Thread Micah Gersten
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]; }

Re: [PHP] Restore Leading Zeros in Zip Codes

2008-08-21 Thread Micah Gersten
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