<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Canada&#8217;s postal code validation in PHP</title>
	<atom:link href="http://roshanbh.com.np/2008/03/canda-postal-code-validation-php.html/feed" rel="self" type="application/rss+xml" />
	<link>http://roshanbh.com.np/2008/03/canda-postal-code-validation-php.html</link>
	<description>Useful Tutorials, Scripts , Tips, and Resources for all PHP and Ajax beginners and experts .</description>
	<lastBuildDate>Wed, 10 Mar 2010 10:59:13 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Riadh</title>
		<link>http://roshanbh.com.np/2008/03/canda-postal-code-validation-php.html/comment-page-1#comment-5110</link>
		<dc:creator>Riadh</dc:creator>
		<pubDate>Fri, 29 Jan 2010 15:03:12 +0000</pubDate>
		<guid isPermaLink="false">http://roshanbh.com.np/2008/03/canda-postal-code-validation-php.html#comment-5110</guid>
		<description>@see http://en.wikipedia.org/wiki/Postal_codes_in_Canada
@see http://en.wikipedia.org/wiki/List_of_postal_codes_in_Canada

well now it&#039;s my last comment! There is my final regular expression.

No postal code includes the letters D, F, I, O, Q, or U, as the OCR equipment used in automated sorting could easily confuse them with other letters and digits[citation needed], especially when they are rendered as cursive handwriting. The letters W and Z are used, but are not currently used as the first letter. 

preg_match(&#039;/^[^dfioquwz][0-9][^dfioqu][0-9][^dfioqu][0-9]$/i&#039;, $zipCode)</description>
		<content:encoded><![CDATA[<p>@see <a href="http://en.wikipedia.org/wiki/Postal_codes_in_Canada" rel="nofollow">http://en.wikipedia.org/wiki/Postal_codes_in_Canada</a><br />
@see <a href="http://en.wikipedia.org/wiki/List_of_postal_codes_in_Canada" rel="nofollow">http://en.wikipedia.org/wiki/List_of_postal_codes_in_Canada</a></p>
<p>well now it&#8217;s my last comment! There is my final regular expression.</p>
<p>No postal code includes the letters D, F, I, O, Q, or U, as the OCR equipment used in automated sorting could easily confuse them with other letters and digits[citation needed], especially when they are rendered as cursive handwriting. The letters W and Z are used, but are not currently used as the first letter. </p>
<p>preg_match(&#8216;/^[^dfioquwz][0-9][^dfioqu][0-9][^dfioqu][0-9]$/i&#8217;, $zipCode)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Riadh</title>
		<link>http://roshanbh.com.np/2008/03/canda-postal-code-validation-php.html/comment-page-1#comment-5108</link>
		<dc:creator>Riadh</dc:creator>
		<pubDate>Fri, 29 Jan 2010 00:24:09 +0000</pubDate>
		<guid isPermaLink="false">http://roshanbh.com.np/2008/03/canda-postal-code-validation-php.html#comment-5108</guid>
		<description>In new found land they have some postal code with (w&#124;z) in the local delivery unit part (the second part). 

for example: 

A0A 3W0 is a valid postal code.
A0A 3W0 &#124; SOUTH RIVER &#124; NEWFOUNDLAND AND LABRADOR &#124; NL &#124; 709 &#124; Y &#124; 47.535964 &#124; -53.209132
A0A 1Z0 is a valid postal code.
A0A 1Z0 &#124; CONCEPTION HARBOUR &#124; NEWFOUNDLAND AND LABRADOR	&#124; NL	&#124; 709 &#124; Y &#124; 47.427521 &#124; -53.225612</description>
		<content:encoded><![CDATA[<p>In new found land they have some postal code with (w|z) in the local delivery unit part (the second part). </p>
<p>for example: </p>
<p>A0A 3W0 is a valid postal code.<br />
A0A 3W0 | SOUTH RIVER | NEWFOUNDLAND AND LABRADOR | NL | 709 | Y | 47.535964 | -53.209132<br />
A0A 1Z0 is a valid postal code.<br />
A0A 1Z0 | CONCEPTION HARBOUR | NEWFOUNDLAND AND LABRADOR	| NL	| 709 | Y | 47.427521 | -53.225612</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Riadh</title>
		<link>http://roshanbh.com.np/2008/03/canda-postal-code-validation-php.html/comment-page-1#comment-5107</link>
		<dc:creator>Riadh</dc:creator>
		<pubDate>Fri, 29 Jan 2010 00:14:38 +0000</pubDate>
		<guid isPermaLink="false">http://roshanbh.com.np/2008/03/canda-postal-code-validation-php.html#comment-5107</guid>
		<description>@see http://www.canadapost.ca/tools/pg/manual/PGaddress-e.asp

As my postal code was not considered to be a valid one, i reviewed your regex and the canada post website and found that only the first char has to represent one of the 18 regions.

I also optimized it to proceed faster.

preg_match(&#039;/^[abceghjklmnprstvxy][0-9][a-z][0-9][a-z][0-9]$/i&#039;, $zip);

@pixelxdesign : there is no need to use strtoupper as the modifier i(caseless) is in the regular expression. And in this case this modifier is fater than the strto(upper&#124;lower) function.</description>
		<content:encoded><![CDATA[<p>@see <a href="http://www.canadapost.ca/tools/pg/manual/PGaddress-e.asp" rel="nofollow">http://www.canadapost.ca/tools/pg/manual/PGaddress-e.asp</a></p>
<p>As my postal code was not considered to be a valid one, i reviewed your regex and the canada post website and found that only the first char has to represent one of the 18 regions.</p>
<p>I also optimized it to proceed faster.</p>
<p>preg_match(&#8216;/^[abceghjklmnprstvxy][0-9][a-z][0-9][a-z][0-9]$/i&#8217;, $zip);</p>
<p>@pixelxdesign : there is no need to use strtoupper as the modifier i(caseless) is in the regular expression. And in this case this modifier is fater than the strto(upper|lower) function.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug H</title>
		<link>http://roshanbh.com.np/2008/03/canda-postal-code-validation-php.html/comment-page-1#comment-5096</link>
		<dc:creator>Doug H</dc:creator>
		<pubDate>Tue, 26 Jan 2010 22:34:54 +0000</pubDate>
		<guid isPermaLink="false">http://roshanbh.com.np/2008/03/canda-postal-code-validation-php.html#comment-5096</guid>
		<description>Why restrict your audience to just Canada?  Why not the world.  Check out http://intlmailaddress.com for a database of postal code formats in all countries in the world.</description>
		<content:encoded><![CDATA[<p>Why restrict your audience to just Canada?  Why not the world.  Check out <a href="http://intlmailaddress.com" rel="nofollow">http://intlmailaddress.com</a> for a database of postal code formats in all countries in the world.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tresloukadu</title>
		<link>http://roshanbh.com.np/2008/03/canda-postal-code-validation-php.html/comment-page-1#comment-4691</link>
		<dc:creator>tresloukadu</dc:creator>
		<pubDate>Thu, 15 Oct 2009 13:52:55 +0000</pubDate>
		<guid isPermaLink="false">http://roshanbh.com.np/2008/03/canda-postal-code-validation-php.html#comment-4691</guid>
		<description>hello, do you know where i can find the adress information of canada? Im developing a system in php with ajax and when de user choses the province all cities are loaded and when a city is loaded all streets are loaded..... Do you know where i can find this database?

thanks</description>
		<content:encoded><![CDATA[<p>hello, do you know where i can find the adress information of canada? Im developing a system in php with ajax and when de user choses the province all cities are loaded and when a city is loaded all streets are loaded&#8230;.. Do you know where i can find this database?</p>
<p>thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: aou</title>
		<link>http://roshanbh.com.np/2008/03/canda-postal-code-validation-php.html/comment-page-1#comment-4316</link>
		<dc:creator>aou</dc:creator>
		<pubDate>Tue, 04 Aug 2009 01:40:21 +0000</pubDate>
		<guid isPermaLink="false">http://roshanbh.com.np/2008/03/canda-postal-code-validation-php.html#comment-4316</guid>
		<description>Have you tried to use Yahoo or Google&#039;s APIs to validate postal code? I&#039;s as simple as sending http request to [google/yahoo] and validating the response.</description>
		<content:encoded><![CDATA[<p>Have you tried to use Yahoo or Google&#8217;s APIs to validate postal code? I&#8217;s as simple as sending http request to [google/yahoo] and validating the response.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mike</title>
		<link>http://roshanbh.com.np/2008/03/canda-postal-code-validation-php.html/comment-page-1#comment-3982</link>
		<dc:creator>mike</dc:creator>
		<pubDate>Sat, 16 May 2009 16:57:33 +0000</pubDate>
		<guid isPermaLink="false">http://roshanbh.com.np/2008/03/canda-postal-code-validation-php.html#comment-3982</guid>
		<description>there are only 18 valid letters for the first character of a postal code and Z is not one of them!</description>
		<content:encoded><![CDATA[<p>there are only 18 valid letters for the first character of a postal code and Z is not one of them!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex G</title>
		<link>http://roshanbh.com.np/2008/03/canda-postal-code-validation-php.html/comment-page-1#comment-3838</link>
		<dc:creator>Alex G</dc:creator>
		<pubDate>Fri, 17 Apr 2009 16:04:17 +0000</pubDate>
		<guid isPermaLink="false">http://roshanbh.com.np/2008/03/canda-postal-code-validation-php.html#comment-3838</guid>
		<description>LOL @ Rakesh... hopefully it somehow involves a high speed collision between you and speeding train...</description>
		<content:encoded><![CDATA[<p>LOL @ Rakesh&#8230; hopefully it somehow involves a high speed collision between you and speeding train&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Fred</title>
		<link>http://roshanbh.com.np/2008/03/canda-postal-code-validation-php.html/comment-page-1#comment-3808</link>
		<dc:creator>Fred</dc:creator>
		<pubDate>Mon, 13 Apr 2009 22:49:10 +0000</pubDate>
		<guid isPermaLink="false">http://roshanbh.com.np/2008/03/canda-postal-code-validation-php.html#comment-3808</guid>
		<description>I used the function  to validate postal code of canada  to check postal code format
But I find it too restrictive
Lots of people use upper case o for Zero and vice versa
also 1 and I (upper case i) are interchangeable
Sure it&#039;s not the correct format, but good enough for mailouts. 

can you post a modified function to allow  for above?</description>
		<content:encoded><![CDATA[<p>I used the function  to validate postal code of canada  to check postal code format<br />
But I find it too restrictive<br />
Lots of people use upper case o for Zero and vice versa<br />
also 1 and I (upper case i) are interchangeable<br />
Sure it&#8217;s not the correct format, but good enough for mailouts. </p>
<p>can you post a modified function to allow  for above?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: seetha</title>
		<link>http://roshanbh.com.np/2008/03/canda-postal-code-validation-php.html/comment-page-1#comment-3023</link>
		<dc:creator>seetha</dc:creator>
		<pubDate>Thu, 30 Oct 2008 09:32:00 +0000</pubDate>
		<guid isPermaLink="false">http://roshanbh.com.np/2008/03/canda-postal-code-validation-php.html#comment-3023</guid>
		<description>I am using PHP and Mysql(database ) I want to send bulk mail but my server not support .. my server guy told send bulk mail using your localhost … can any one help me.how can i send bulk mail ….. ?????

i am using php and mysql i want to send bulk but server not support ..my server guy told send bulk mail using your localhost can.. any one help me how can i send bulk mail..?????</description>
		<content:encoded><![CDATA[<p>I am using PHP and Mysql(database ) I want to send bulk mail but my server not support .. my server guy told send bulk mail using your localhost … can any one help me.how can i send bulk mail ….. ?????</p>
<p>i am using php and mysql i want to send bulk but server not support ..my server guy told send bulk mail using your localhost can.. any one help me how can i send bulk mail..?????</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pixelxdesign</title>
		<link>http://roshanbh.com.np/2008/03/canda-postal-code-validation-php.html/comment-page-1#comment-2318</link>
		<dc:creator>pixelxdesign</dc:creator>
		<pubDate>Thu, 11 Sep 2008 02:23:46 +0000</pubDate>
		<guid isPermaLink="false">http://roshanbh.com.np/2008/03/canda-postal-code-validation-php.html#comment-2318</guid>
		<description>@Mr. Gift Baskets

You can just add str_replace in the function...

&lt;?



/**
 * validateCanadaZip()
 *
 * function to validate postal code of canada
 * @source http://roshanbh.com.np/2008/03/canda-postal-code-validation-php.html
 *  {@modified by} Fred-Eric Lafaille, http://www.pixelxdesign.com/
 *   
 * 
 * 
 * @param mixed $zip_code
 * @return array ()
 */
function validateCanadaZip($zip_code)
{
$zip_code = strtoupper($zip_code);
$zip_code = str_replace(&quot; &quot;, &quot;&quot;, $zip_code);
$zip_code = str_replace(&quot;-&quot;, &quot;&quot;, $zip_code);

$count = count( $zip_code);



if(strlen($zip_code)  6) {
			return array(false, $zip_code. &quot; 0x0001&quot;);
		}

 //function by Roshan Bhattara(http://roshanbh.com.np)
 if(preg_match(&quot;/^([a-ceghj-npr-tv-z]){1}[0-9]{1}[a-ceghj-npr-tv-z]{1}[0-9]{1}[a-ceghj-npr-tv-z]{1}[0-9]{1}$/i&quot;,$zip_code))
    return array(true, $zip_code);
 else
    return array(false, $zip_code);
}




$zipcode = &quot;h7w 5c6&quot;;
$result = validateCanadaZip($zipcode);
if ($result[&#039;0&#039;]) {
	print $result[&#039;1&#039;] .&quot; est valide&quot;;
} else {
	print $result[&#039;1&#039;] .&quot; est non-valide&quot;;
}

?&gt;</description>
		<content:encoded><![CDATA[<p>@Mr. Gift Baskets</p>
<p>You can just add str_replace in the function&#8230;</p>
<p>&lt;?</p>
<p>/**<br />
 * validateCanadaZip()<br />
 *<br />
 * function to validate postal code of canada<br />
 * @source <a href="http://roshanbh.com.np/2008/03/canda-postal-code-validation-php.html" rel="nofollow">http://roshanbh.com.np/2008/03/canda-postal-code-validation-php.html</a><br />
 *  {@modified by} Fred-Eric Lafaille, <a href="http://www.pixelxdesign.com/" rel="nofollow">http://www.pixelxdesign.com/</a><br />
 *<br />
 *<br />
 *<br />
 * @param mixed $zip_code<br />
 * @return array ()<br />
 */<br />
function validateCanadaZip($zip_code)<br />
{<br />
$zip_code = strtoupper($zip_code);<br />
$zip_code = str_replace(&#8221; &#8220;, &#8220;&#8221;, $zip_code);<br />
$zip_code = str_replace(&#8220;-&#8221;, &#8220;&#8221;, $zip_code);</p>
<p>$count = count( $zip_code);</p>
<p>if(strlen($zip_code)  6) {<br />
			return array(false, $zip_code. &#8221; 0&#215;0001&#8243;);<br />
		}</p>
<p> //function by Roshan Bhattara(http://roshanbh.com.np)<br />
 if(preg_match(&#8220;/^([a-ceghj-npr-tv-z]){1}[0-9]{1}[a-ceghj-npr-tv-z]{1}[0-9]{1}[a-ceghj-npr-tv-z]{1}[0-9]{1}$/i&#8221;,$zip_code))<br />
    return array(true, $zip_code);<br />
 else<br />
    return array(false, $zip_code);<br />
}</p>
<p>$zipcode = &#8220;h7w 5c6&#8243;;<br />
$result = validateCanadaZip($zipcode);<br />
if ($result['0']) {<br />
	print $result['1'] .&#8221; est valide&#8221;;<br />
} else {<br />
	print $result['1'] .&#8221; est non-valide&#8221;;<br />
}</p>
<p>?&gt;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: KranF.com - Le Blogue &#187; Archive du blogue &#187; Valider un code postal Canadien en PHP</title>
		<link>http://roshanbh.com.np/2008/03/canda-postal-code-validation-php.html/comment-page-1#comment-2057</link>
		<dc:creator>KranF.com - Le Blogue &#187; Archive du blogue &#187; Valider un code postal Canadien en PHP</dc:creator>
		<pubDate>Thu, 28 Aug 2008 22:13:39 +0000</pubDate>
		<guid isPermaLink="false">http://roshanbh.com.np/2008/03/canda-postal-code-validation-php.html#comment-2057</guid>
		<description>[...] Pour ce faire j&#8217;ai fait une recherche rapide sur Google qui m&#8217;a permis de découvrir une solution toute préparée à l&#8217;avance! [...]</description>
		<content:encoded><![CDATA[<p>[...] Pour ce faire j&#8217;ai fait une recherche rapide sur Google qui m&#8217;a permis de découvrir une solution toute préparée à l&#8217;avance! [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mr. Gift Baskets</title>
		<link>http://roshanbh.com.np/2008/03/canda-postal-code-validation-php.html/comment-page-1#comment-1751</link>
		<dc:creator>Mr. Gift Baskets</dc:creator>
		<pubDate>Fri, 08 Aug 2008 13:45:15 +0000</pubDate>
		<guid isPermaLink="false">http://roshanbh.com.np/2008/03/canda-postal-code-validation-php.html#comment-1751</guid>
		<description>Hi Roshan, thank you for the great piece of code.  One minor issue, the code requires 6 continuous characters, but many people put a space in the middle to make it A2A 2A2 instead of A2A2A2. Some international visitors might also do A2A2 A2 if that&#039;s the format of their own country&#039;s postal code. How can I allow for any spaces between characters?

The Gift Basket King :) (a.k.a James)</description>
		<content:encoded><![CDATA[<p>Hi Roshan, thank you for the great piece of code.  One minor issue, the code requires 6 continuous characters, but many people put a space in the middle to make it A2A 2A2 instead of A2A2A2. Some international visitors might also do A2A2 A2 if that&#8217;s the format of their own country&#8217;s postal code. How can I allow for any spaces between characters?</p>
<p>The Gift Basket King <img src='http://roshanbh.com.np/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  (a.k.a James)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rakesh</title>
		<link>http://roshanbh.com.np/2008/03/canda-postal-code-validation-php.html/comment-page-1#comment-1220</link>
		<dc:creator>rakesh</dc:creator>
		<pubDate>Wed, 18 Jun 2008 10:55:00 +0000</pubDate>
		<guid isPermaLink="false">http://roshanbh.com.np/2008/03/canda-postal-code-validation-php.html#comment-1220</guid>
		<description>I am using PHP and Mysql(database )  I want to send bulk mail but my server not support .. my server guy told send bulk mail using your localhost ... can any one help me.how can i send bulk mail ..... ?????</description>
		<content:encoded><![CDATA[<p>I am using PHP and Mysql(database )  I want to send bulk mail but my server not support .. my server guy told send bulk mail using your localhost &#8230; can any one help me.how can i send bulk mail &#8230;.. ?????</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Roshan</title>
		<link>http://roshanbh.com.np/2008/03/canda-postal-code-validation-php.html/comment-page-1#comment-517</link>
		<dc:creator>Roshan</dc:creator>
		<pubDate>Wed, 26 Mar 2008 06:54:13 +0000</pubDate>
		<guid isPermaLink="false">http://roshanbh.com.np/2008/03/canda-postal-code-validation-php.html#comment-517</guid>
		<description>sorry for the confustion..that was mistakenly typed and corrected.....thanks a lott</description>
		<content:encoded><![CDATA[<p>sorry for the confustion..that was mistakenly typed and corrected&#8230;..thanks a lott</p>
]]></content:encoded>
	</item>
</channel>
</rss>
