<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" 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/" version="2.0">

<channel>
	<title>Talk In Code</title>
	
	<link>http://www.talkincode.com</link>
	<description>Code tips, snippets and resources.</description>
	<pubDate>Tue, 02 Jun 2009 20:08:58 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/TalkInCode" type="application/rss+xml" /><item>
		<title>My Final Post</title>
		<link>http://www.talkincode.com/my-final-post-1206.html</link>
		<comments>http://www.talkincode.com/my-final-post-1206.html#comments</comments>
		<pubDate>Tue, 02 Jun 2009 20:08:58 +0000</pubDate>
		<dc:creator>Tech</dc:creator>
		
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.talkincode.com/?p=1206</guid>
		<description><![CDATA[The time has come for me to stop writing on Talk In Code. It has been a fun couple of years, and I have learnt a lot, but as of today I will not be able to write any more posts on this blog. I want to thank everyone who has posted comments and contributed [...]]]></description>
			<content:encoded><![CDATA[<p>The time has come for me to stop writing on Talk In Code. It has been a fun couple of years, and I have learnt a lot, but as of today I will not be able to write any more posts on this blog. I want to thank everyone who has posted comments and contributed to the site since I have been writing.</p>
<p>You might see the blog being updated non-regularly in the future as I have now passed the rains on to someone else.</p>
<p>This is Tech, signing off.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.talkincode.com/my-final-post-1206.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>Extract Keywords From A Text String With PHP</title>
		<link>http://www.talkincode.com/extract-keywords-from-a-text-string-with-php-1204.html</link>
		<comments>http://www.talkincode.com/extract-keywords-from-a-text-string-with-php-1204.html#comments</comments>
		<pubDate>Thu, 21 May 2009 16:34:47 +0000</pubDate>
		<dc:creator>Tech</dc:creator>
		
		<category><![CDATA[PHP Strings]]></category>

		<category><![CDATA[function]]></category>

		<category><![CDATA[keywords]]></category>

		<category><![CDATA[string]]></category>

		<category><![CDATA[text]]></category>

		<category><![CDATA[vending machines]]></category>

		<guid isPermaLink="false">http://www.talkincode.com/?p=1204</guid>
		<description><![CDATA[A common issue I have come across in the past is that I have a CMS system, or an old copy of Wordpress, and I need to create a set of keywords to be used in the meta keywords field.  To solve this I put together a simple function that runs through a string [...]]]></description>
			<content:encoded><![CDATA[<p>A common issue I have come across in the past is that I have a CMS system, or an old copy of Wordpress, and I need to create a set of keywords to be used in the meta keywords field.  To solve this I put together a simple function that runs through a string and picks out the most commonly used words in that list as an array.  This is currently set to be 10, but you can change that quite easily.</p>
<p>The first thing the function defines is a list of &quot;stop&quot; words. This is a list of words that occur quite a bit in English text and would therefore interfere with the outcome of the function. The function also uses a variant of the slug function to remove any odd characters that might be in the text.</p>
<p><code class="php">function commonWords($string){<br />
&nbsp;&nbsp;&nbsp;&nbsp;$stopWords = array(&#39;i&#39;,&#39;a&#39;,&#39;about&#39;,&#39;an&#39;,&#39;and&#39;,&#39;are&#39;,&#39;as&#39;,&#39;at&#39;,&#39;be&#39;,&#39;by&#39;,&#39;com&#39;,&#39;de&#39;,&#39;en&#39;,&#39;for&#39;,&#39;from&#39;,&#39;how&#39;,&#39;in&#39;,&#39;is&#39;,&#39;it&#39;,&#39;la&#39;,&#39;of&#39;,&#39;on&#39;,&#39;or&#39;,&#39;that&#39;,&#39;the&#39;,&#39;this&#39;,&#39;to&#39;,&#39;was&#39;,&#39;what&#39;,&#39;when&#39;,&#39;where&#39;,&#39;who&#39;,&#39;will&#39;,&#39;with&#39;,&#39;und&#39;,&#39;the&#39;,&#39;www&#39;);<br />
&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;$string = preg_replace(&#39;/ss+/i&#39;, &#39;&#39;, $string);<br />
&nbsp;&nbsp;&nbsp;&nbsp;$string = trim($string); // trim the string<br />
&nbsp;&nbsp;&nbsp;&nbsp;$string = preg_replace(&#39;/[^a-zA-Z0-9 -]/&#39;, &#39;&#39;, $string); // only take alphanumerical characters, but keep the spaces and dashes too…<br />
&nbsp;&nbsp;&nbsp;&nbsp;$string = strtolower($string); // make it lowercase<br />
&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;preg_match_all(&#39;/([a-z]*?)(?=s)/i&#39;, $string, $matchWords);<br />
&nbsp;&nbsp;&nbsp;&nbsp;$matchWords = $matchWords[0];<br />
&nbsp;&nbsp;&nbsp;&nbsp;foreach ( $matchWords as $key=&gt;$item ) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ( $item == &#39;&#39; || in_array(strtolower($item), $stopWords) || strlen($item) &lt;= 3 ) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;unset($matchWords[$key]);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;$wordCountArr = array();<br />
&nbsp;&nbsp;&nbsp;&nbsp;if ( is_array($matchWords) ) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;foreach ( $matchWords as $key =&gt; $val ) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$val = strtolower($val);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ( isset($wordCountArr[$val]) ) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$wordCountArr[$val]++;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} else {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$wordCountArr[$val] = 1;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;arsort($wordCountArr);<br />
&nbsp;&nbsp;&nbsp;&nbsp;$wordCountArr = array_slice($wordCountArr, 0, 10);<br />
&nbsp;&nbsp;&nbsp;&nbsp;return $wordCountArr;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
}</code></p>
<p>Here is an example of the function in action.</p>
<p><code class="php">$text = &quot;This is some text. This is some text. <a href="http://www.linkvending.co.uk/" title="Vending Machines">Vending Machines</a> are great.&quot;;<br />
$words = commonWords($text);<br />
echo implode(&#39;,&#39;, array_keys($words));</code></p>
<p>This produces the following output.</p>
<p><code class="php">some,text,machines,vending</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.talkincode.com/extract-keywords-from-a-text-string-with-php-1204.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>Excel Document Scanning With Zend_Search_Lucene</title>
		<link>http://www.talkincode.com/excel-document-scanning-with-zend_search_lucene-1195.html</link>
		<comments>http://www.talkincode.com/excel-document-scanning-with-zend_search_lucene-1195.html#comments</comments>
		<pubDate>Mon, 11 May 2009 09:25:21 +0000</pubDate>
		<dc:creator>Tech</dc:creator>
		
		<category><![CDATA[Zend Framework]]></category>

		<category><![CDATA[Excel]]></category>

		<category><![CDATA[PHP]]></category>

		<category><![CDATA[Zend_Search_Lucene_Document_Xlsx]]></category>

		<guid isPermaLink="false">http://www.talkincode.com/?p=1195</guid>
		<description><![CDATA[Zend_Search_Lucene offers some powerful document scanning capabilities, and there are a few different formats that are useful for the search engine to index.
To allow the indexing and searching of Excel documents using Zend_Search_Lucene you need to use the Zend_Search_Lucene_Document_Xlsx class. However, to use this class you must have the Zip module installed with PHP.  [...]]]></description>
			<content:encoded><![CDATA[<p>Zend_Search_Lucene offers some powerful <a href="http://www.microstat.co.uk/" title="Document scanning">document scanning</a> capabilities, and there are a few different formats that are useful for the search engine to index.</p>
<p>To allow the indexing and searching of Excel documents using Zend_Search_Lucene you need to use the Zend_Search_Lucene_Document_Xlsx class. However, to use this class you must have the Zip module installed with PHP.  For Windows users this means editing your php.ini file and uncommenting the following line:</p>
<p><code>extension=php_zip.dll</code></p>
<p>For Linux users you will need to recompile PHP with the &#8211;enable-zip configure option.</p>
<p>Create and/or open the index in the normal way and you can index Excel documents using the following code.</p>
<p><code class="php">$filename = &#39;C:\Book1.xlsx&#39;;<br />
$doc = Zend_Search_Lucene_Document_Xlsx::loadXlsxFile($filename);<br />
$index-&gt;addDocument($doc);</code></p>
<p>You can now set up a query and search for the document in the following way, although you would normally expect the input string to be some kind of user input.</p>
<p><code class="php">$queryStr = &#39;wibble&#39;;<br />
$userQuery = Zend_Search_Lucene_Search_QueryParser::parse($queryStr);<br />
&nbsp;<br />
$query = new Zend_Search_Lucene_Search_Query_Boolean();<br />
$query-&gt;addSubquery($userQuery, true);<br />
&nbsp;<br />
&nbsp;<br />
$hits = $index-&gt;find($query);<br />
&nbsp;<br />
foreach ( $hits as $hit ) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;echo $hit-&gt;score.&#39;&lt;br /&gt;&#39;;<br />
&nbsp;&nbsp;&nbsp;&nbsp;echo $hit-&gt;filename.&#39;&lt;br /&gt;&#39;;<br />
}</code></p>
<p>The score is always returned with a hit object. Other parameters available to display are filename, title, subject, creator, keywords, description, lastModifiedBy, revision, modified, created. However, some of these depend on the contents of the document. It is possible to add keywords and subjects to an Excel document, so if they are not present then you will need to check for the existence of that parameter before displaying it.  The following code looks for the existence of the keyword parameter before trying to print it out.</p>
<p><code class="php">if ( isset($hit-&gt;keywords) ) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;echo $hit-&gt;keywords.&#39;&lt;br /&gt;&#39;;<br />
}</code></p>
<p>By default, this function indexes the document meta data and will tokenise and store the tokens as an index. The loadXlsxFile() function has a second optional parameter which is by default set to false. If this is set to true the contents of the Excel document will be included in the index.  You can then use the following code to print out the contents of the document.</p>
<p><code>echo .$hit-&gt;body.&#39;&lt;br /&gt;&#39;;</code></p>
<p>Bear in mind that this output will not contain any row or column information and will therefore look like a dump of the data.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.talkincode.com/excel-document-scanning-with-zend_search_lucene-1195.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>Multi Page Forms In PHP</title>
		<link>http://www.talkincode.com/multi-page-forms-in-php-1171.html</link>
		<comments>http://www.talkincode.com/multi-page-forms-in-php-1171.html#comments</comments>
		<pubDate>Tue, 05 May 2009 11:14:03 +0000</pubDate>
		<dc:creator>Tech</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[form]]></category>

		<category><![CDATA[get]]></category>

		<category><![CDATA[multi]]></category>

		<category><![CDATA[multipage]]></category>

		<category><![CDATA[page]]></category>

		<category><![CDATA[post]]></category>

		<category><![CDATA[session]]></category>

		<guid isPermaLink="false">http://www.talkincode.com/?p=1171</guid>
		<description><![CDATA[Multi pages forms are just as they sound, a single form spread across multiple pages. These are useful in terms of usability as it can break up an otherwise dauntingly big form into smaller chunks. It can also be useful if you want to process some of the results in order to determine what forms [...]]]></description>
			<content:encoded><![CDATA[<p>Multi pages forms are just as they sound, a single form spread across multiple pages. These are useful in terms of usability as it can break up an otherwise dauntingly big form into smaller chunks. It can also be useful if you want to process some of the results in order to determine what forms the user sees on later steps.</p>
<p>There are two ways in which it is possible to do this using PHP.</p>
<p>The first (and simplest) is just to cycle through the items submitted on a previous form and print them out as hidden fields. Our first page source code will look like this:</p>
<p><code>&lt;form action=&quot;form2.php&quot; method=&quot;get&quot;&gt;<br />
Name: &lt;input type=&quot;text&quot; name=&quot;name&quot; /&gt;<br />
&lt;br /&gt;<br />
&lt;input type=&quot;submit&quot; value=&quot;Proceed&quot;&gt;<br />
&lt;/form&gt;</code></p>
<p>On submitting the form we are taken to form2.php, which asks the user a different question and prints out the hidden fields.  Because we used a get request for our first form we need to use the $_GET array.</p>
<p><code class="php">&lt;form action=&quot;end.php&quot; method=&quot;get&quot;&gt;<br />
Colour: &lt;input type=&quot;text&quot; name=&quot;colour&quot; /&gt;<br />
&lt;br /&gt;<br />
&lt;?php<br />
foreach ( $_GET as $key=&gt;$value ) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;if ( $key!=&quot;submit&quot; ) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$value = htmlentities(stripslashes(strip_tags($value)));<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;t&lt;input type=&quot;hidden&quot; name=&quot;$key&quot; value=&quot;$value&quot;&gt;\n&quot;;<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
}<br />
?&gt;<br />
&lt;input type=&quot;submit&quot; value=&quot;Proceed&quot;&gt;<br />
&lt;/form&gt;</code></p>
<p>This same code can be used on the different pages of the form.  This method is fine, and works quite well, but it doesn&#8217;t account for users going back through the form and resubmitting a previous item.  The $_GET array will only contain information about the previous forms.</p>
<p>To make this more user friendly, and robust, we need to employ a session to store our form values as the user goes through the form.  Using sessions means that the user can cycle back and forward through the forms with no ill effect on the form data.  The following code will take the input of the previous form and save it as a PHP session.</p>
<p><code class="php">session_start();<br />
foreach ( $_GET as $key=&gt;$value ) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;if ( $key!=&quot;submit&quot; ) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$value = htmlentities(stripslashes(strip_tags($value)));<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$_SESSION[$key] = $value;<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
}</code></p>
<p>This must be included on every page of our multi page form. If it is not then the data will simply not be saved for that step. Your users can now move back and forward through the forms, saving the information as they go.  You need to supply a back button for this to work as using the browser back and forward buttons will also not save the data.</p>
<p>Finally, when testing this code I found that using GET rather than POST was beneficial in terms of usability. This is mainly because if you use POST requests and the user clicks the back on their browser they will be asked if they want to resubmit the information for that form.</p>
<p>Does anyone else have any ideas about how to do this? If so then post a comment and suggest it. You can even put a post in the forum!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.talkincode.com/multi-page-forms-in-php-1171.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>Validate EAN13 Barcodes</title>
		<link>http://www.talkincode.com/validate-ean13-barcodes-1185.html</link>
		<comments>http://www.talkincode.com/validate-ean13-barcodes-1185.html#comments</comments>
		<pubDate>Thu, 30 Apr 2009 08:31:12 +0000</pubDate>
		<dc:creator>Tech</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[barcode]]></category>

		<category><![CDATA[ean13]]></category>

		<category><![CDATA[function]]></category>

		<category><![CDATA[validate]]></category>

		<guid isPermaLink="false">http://www.talkincode.com/?p=1185</guid>
		<description><![CDATA[EAN13 barcodes are commonly used to label products in Europe. If you want to know more about how they work then please view the Wikipedia entry on European Article Numbers.
EAN13 barcodes are actually 12 digits long and are validated by using a check digit, which is placed at the end, making the code 13 digits [...]]]></description>
			<content:encoded><![CDATA[<p>EAN13 barcodes are commonly used to label products in Europe. If you want to know more about how they work then please view the Wikipedia entry on <a href="http://en.wikipedia.org/wiki/European_Article_Number" title="European Article Number">European Article Numbers</a>.</p>
<p>EAN13 barcodes are actually 12 digits long and are validated by using a check digit, which is placed at the end, making the code 13 digits long.  The check digit is worked out by the following process:</p>
<ul>
<li>Add up all of the even numbers and multiply this number by 3.</li>
<li>Add up all of the odd numbers and add this result to the result of the even numbers.</li>
<li>Divide the number by 10 and keep the remainder (modulo).</li>
<li>If the remainder is not 0 then subtract 10 from this number.</li>
</ul>
<p>Here is a function that runs through those steps, but also check to see what length the barcode is. If it is 13 digits long then it returns both the original check digit and the calculated check digit. If the barcode is 12 digits long then it returns the checksum. In both cases the original barcode is also returned.</p>
<p><code class="php">function validateEan13($digits)<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;$originalcheck = false;<br />
&nbsp;&nbsp;&nbsp;&nbsp;if ( strlen($digits) == 13 ) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$originalcheck = substr($digits, -1);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$digits = substr($digits, 0, -1);<br />
&nbsp;&nbsp;&nbsp;&nbsp;} elseif ( strlen($digits) != 12 ) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Invalid EAN13 barcode<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return false;<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;// Add even numbers together<br />
&nbsp;&nbsp;&nbsp;&nbsp;$even = $digits[1] + $digits[3] + $digits[5] + $digits[7] + $digits[9] + $digits[11];<br />
&nbsp;&nbsp;&nbsp;&nbsp;// Multiply this result by 3<br />
&nbsp;&nbsp;&nbsp;&nbsp;$even = $even * 3;<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;// Add odd numbers together<br />
&nbsp;&nbsp;&nbsp;&nbsp;$odd = $digits[0] + $digits[2] + $digits[4] + $digits[6] + $digits[8] + $digits[10];<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;// Add two totals together<br />
&nbsp;&nbsp;&nbsp;&nbsp;$total = $even + $odd;<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;// Calculate the checksum<br />
&nbsp;&nbsp;&nbsp;&nbsp;// Divide total by 10 and store the remainder<br />
&nbsp;&nbsp;&nbsp;&nbsp;$checksum = $total % 10;<br />
&nbsp;&nbsp;&nbsp;&nbsp;// If result is not 0 then take away 10<br />
&nbsp;&nbsp;&nbsp;&nbsp;if($checksum != 0){<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$checksum = 10 - $checksum;<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;// Return results.<br />
&nbsp;&nbsp;&nbsp;&nbsp;if ( $originalcheck !== false ) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return array(&#39;barcode&#39;=&gt;$digits, &#39;checksum&#39;=&gt;$checksum, &#39;originalcheck&#39;=&gt;$originalcheck);<br />
&nbsp;&nbsp;&nbsp;&nbsp;} else {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return array(&#39;barcode&#39;=&gt;$digits, &#39;checksum&#39;=&gt;$checksum);<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
}</code></p>
<p>To test this I ran a few codes through the function.</p>
<p><code class="php">echo &#39;&lt;pre&gt;&#39;;<br />
// two normal barcodes<br />
print_r(validateEan13(5023920187205));<br />
print_r(validateEan13(5010548001860));<br />
// one short barcode to work out checksum<br />
print_r(validateEan13(501054800186));<br />
// a normal barcode<br />
print_r(validateEan13(5034504935778));<br />
// the same barcode with a broken number<br />
print_r(validateEan13(5034504735778));<br />
// two random numbers, one of which is not long enough to be an EA13 barcode<br />
print_r(validateEan13(7233897438712));<br />
var_dump(validateEan13(3345345345));<br />
echo &#39;&lt;/pre&gt;&#39;;</code></p>
<p>This prints out the following results, which I have annotated for your convenience.</p>
<p><code>// two normal barcodes<br />
Array<br />
(<br />
&nbsp;&nbsp;&nbsp;&nbsp;[barcode] =&gt; 502392018720<br />
&nbsp;&nbsp;&nbsp;&nbsp;[checksum] =&gt; 5<br />
&nbsp;&nbsp;&nbsp;&nbsp;[originalcheck] =&gt; 5<br />
)<br />
Array<br />
(<br />
&nbsp;&nbsp;&nbsp;&nbsp;[barcode] =&gt; 501054800186<br />
&nbsp;&nbsp;&nbsp;&nbsp;[checksum] =&gt; 0<br />
&nbsp;&nbsp;&nbsp;&nbsp;[originalcheck] =&gt; 0<br />
)<br />
// one short barcode to work out checksum<br />
Array<br />
(<br />
&nbsp;&nbsp;&nbsp;&nbsp;[barcode] =&gt; 501054800186<br />
&nbsp;&nbsp;&nbsp;&nbsp;[checksum] =&gt; 0<br />
)<br />
&nbsp;<br />
// a normal barcode<br />
Array<br />
(<br />
&nbsp;&nbsp;&nbsp;&nbsp;[barcode] =&gt; 503450493577<br />
&nbsp;&nbsp;&nbsp;&nbsp;[checksum] =&gt; 8<br />
&nbsp;&nbsp;&nbsp;&nbsp;[originalcheck] =&gt; 8<br />
)<br />
// the same barcode with a broken number<br />
Array<br />
(<br />
&nbsp;&nbsp;&nbsp;&nbsp;[barcode] =&gt; 503450473577<br />
&nbsp;&nbsp;&nbsp;&nbsp;[checksum] =&gt; 4<br />
&nbsp;&nbsp;&nbsp;&nbsp;[originalcheck] =&gt; 8<br />
)<br />
// two random numbers, one of which is not long enough to be an EA13 barcode<br />
Array<br />
(<br />
&nbsp;&nbsp;&nbsp;&nbsp;[barcode] =&gt; 723389743871<br />
&nbsp;&nbsp;&nbsp;&nbsp;[checksum] =&gt; 4<br />
&nbsp;&nbsp;&nbsp;&nbsp;[originalcheck] =&gt; 2<br />
)<br />
bool(false)</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.talkincode.com/validate-ean13-barcodes-1185.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>Create A Tag Cloud Page In Wordpress</title>
		<link>http://www.talkincode.com/create-a-tag-cloud-page-in-wordpress-1180.html</link>
		<comments>http://www.talkincode.com/create-a-tag-cloud-page-in-wordpress-1180.html#comments</comments>
		<pubDate>Tue, 28 Apr 2009 08:56:22 +0000</pubDate>
		<dc:creator>Tech</dc:creator>
		
		<category><![CDATA[Wordpress]]></category>

		<category><![CDATA[page]]></category>

		<category><![CDATA[PHP]]></category>

		<category><![CDATA[print]]></category>

		<category><![CDATA[tag]]></category>

		<category><![CDATA[tag cloud]]></category>

		<category><![CDATA[template]]></category>

		<guid isPermaLink="false">http://www.talkincode.com/?p=1180</guid>
		<description><![CDATA[A tag cloud is a name for a collection of keywords that are displayed as a big block of text. Usually the most commonly occurring keyword is the largest, and the least commonly occurring keyword is the smallest.  Tag clouds are a neat way of allowing your users to navigate your content in a [...]]]></description>
			<content:encoded><![CDATA[<p>A tag cloud is a name for a collection of keywords that are displayed as a big block of text. Usually the most commonly occurring keyword is the largest, and the least commonly occurring keyword is the smallest.  Tag clouds are a neat way of allowing your users to navigate your content in a different way, simply be letting them look over the cloud and linking each keyword to sections of your site that contain that word.</p>
<p>Wordpress comes with this function built in and is already available as a widget. However, after adding a few hundred posts this tag cloud can get rather large and this widget can stretch your sidebar to stupid proportions.  A way around this is to create a page that can be used to display this large tag cloud.  The first step is to create a page template that will be used to run the correct Wordpress function to display the tags.  This is done by making a copy of your normal page template (call it tagpage.php) and adding the following code at the top.</p>
<p><code class="php">&lt;?php<br />
/*<br />
Template Name: Tags<br />
*/<br />
?&gt;</code></p>
<p>When you go to create a page you will see a list of available templates to select from, one of these will be called Tags.  Add in your title and some descriptive text and select this template.</p>
<p>Next, we need to add a call to the wp_tag_cloud() function, this basically prints out a small tag cloud.  Add the following code into your page template so that is fits in with the rest of your design.</p>
<p><code class="php">&lt;?php wp_tag_cloud(); ?&gt;</code></p>
<p>As with most Wordpress functions, wp_tag_cloud() allows you to add lots of parameters to change the output of the function.  There are lots of different options available, but the main ones that will be used are as follows:</p>
<ul>
<li><strong>smallest</strong> - This designates the font size to be used for the least commonly occurring tag.  The units are by default in &#39;pt&#39; or points, but this can be changed via the unit parameter.</li>
<li><strong>largest</strong> - This designates the font size to be used for the most commonly occurring tag.</li>
<li><strong>unit</strong> - Unit of measure as pertains to the smallest and largest values. This can be any CSS length value, e.g. pt, px, em, %; default is pt (points).</li>
<li><strong>number</strong> - This tells the function how many tags to include in the tag cloud.  The default is 45, but to print out all tags just use 0.</li>
</ul>
<p>These parameters are given as an encoded string, for example, to change the number of tags printed from the default of 45 to 20 use the following code.</p>
<p><code class="php">&lt;?php wp_tag_cloud(&#39;number=20&#39;); ?&gt;</code></p>
<p>Multiple parameters are separated by the &amp; character.</p>
<p><code class="php">&lt;?php wp_tag_cloud(&#39;number=20&amp;largest=200&#39;); ?&gt;</code></p>
<p>Take a look at the Wordpress manual for more information about the <a href="http://codex.wordpress.org/Template_Tags/wp_tag_cloud" title="wp_tag_cloud">wp_tag_cloud()</a> function</p>
<p>To demonstrate I have created a <a href="http://www.talkincode.com/tags" title="Tag cloud page">tag cloud page</a> on Talk In Code, using the following code to create the cloud.</p>
<p><code class="php">&lt;?php wp_tag_cloud(&#39;smallest=7&amp;largest=50&amp;number=500&#39;); ?&gt;</code></p>
<p>Finally, there is also a function called  wp_generate_tag_cloud() that has the same functionality as wp_tag_cloud() but will always return the HTML string that makes the tag cloud.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.talkincode.com/create-a-tag-cloud-page-in-wordpress-1180.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>Hide And Unhide Code With PHP</title>
		<link>http://www.talkincode.com/hide-and-unhide-code-with-php-1168.html</link>
		<comments>http://www.talkincode.com/hide-and-unhide-code-with-php-1168.html#comments</comments>
		<pubDate>Mon, 27 Apr 2009 09:49:13 +0000</pubDate>
		<dc:creator>Tech</dc:creator>
		
		<category><![CDATA[PHP Strings]]></category>

		<category><![CDATA[char]]></category>

		<category><![CDATA[code]]></category>

		<category><![CDATA[hide]]></category>

		<category><![CDATA[obfuscate]]></category>

		<category><![CDATA[ord]]></category>

		<category><![CDATA[PHP]]></category>

		<category><![CDATA[software]]></category>

		<category><![CDATA[unhide]]></category>

		<guid isPermaLink="false">http://www.talkincode.com/?p=1168</guid>
		<description><![CDATA[If you are selling a system the last thing you want is for people to copy the system and pass it on for free. There are numerous ways to implement parts of the system that will stop this from happening.
By far the easiest is to create a section of code that is hidden, the removal [...]]]></description>
			<content:encoded><![CDATA[<p>If you are selling a system the last thing you want is for people to copy the system and pass it on for free. There are numerous ways to implement parts of the system that will stop this from happening.</p>
<p>By far the easiest is to create a section of code that is hidden, the removal of which will cause the application to fall over.  It could even be as simple as a link back to your site so that even if you give you application away for free, you will always have that link present.</p>
<p>This method involves the use of a function called eval(), which takes PHP code as a string and interprets it to produce output.  Here is an example that prints a link to Talk In Code.</p>
<p><code class="php">$code = &quot;echo &quot;&lt;a href=&#39;http://www.talkincode.com/&#39; title&#39;Talk In Code&#39;&gt;Talk In Code&lt;/a&gt;&quot;;&quot;;<br />
eval($code);</code></p>
<p>So lets use some code to hide this from anyone who might be reading our source code.  First we pass this string through our hiding function to produce non-human readable text.  This function is called obfuscate() and works by taking each character in turn and converting it into the ascii equivalent.</p>
<p><code class="php">function obfuscate($text) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;$length = strlen($text);<br />
&nbsp;&nbsp;&nbsp;&nbsp;$scrambled = &#39;&#39;;<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;for ($i = 0; $i &lt; $length; ++$i) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$scrambled .= ord($text[$i]). &#39; &#39;;<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;return $scrambled;<br />
}<br />
$code = &quot;echo &quot;&lt;a href=&#39;http://www.talkincode.com/&#39; title&#39;Talk In Code&#39;&gt;Talk In Code&lt;/a&gt;&quot;;&quot;;<br />
&nbsp;<br />
$obf = obfuscate($code);<br />
echo $obf;<br />
</code></p>
<p>This will print out the following:</p>
<p><code>101 99 104 111 32 34 60 97 32 104 114 101 102 61 39 104 116 116 112 58 47 47 119 119 119 46 116 97 108 107 105 110 99 111 100 101 46 99 111 109 47 39 32 116 105 116 108 101 39 84 97 108 107 32 73 110 32 67 111 100 101 39 62 84 97 108 107 32 73 110 32 67 111 100 101 60 47 97 62 34 59</code></p>
<p>We can store this as a variable until we next need it. In order to run this code we need to convert it into something that eval() can understand, to do this we use the opposite of the obfuscate(), called unobfuscate().  This function works by taking a set of ascii values and converting them into their character equivalents, note that we also trim the text to remove the last space from the end of the code.</p>
<p><code class="php">function unobfuscate($scrambled) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;$text = &#39;&#39;;<br />
&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;$bits = explode(&#39; &#39;,$scrambled);<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;foreach ( $bits as $bit ) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$text .= chr($bit);<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;return trim($text);<br />
}</code></p>
<p>We can then transform our hidden code into PHP code, which is then passed to the eval() function and run.</p>
<p><code class="php">$code = &#39;101 99 104 111 32 34 60 97 32 104 114 101 102 61 39 104 116 116 112 58 47 47 119 119 119 46 116 97 108 107 105 110 99 111 100 101 46 99 111 109 47 39 32 116 105 116 108 101 39 84 97 108 107 32 73 110 32 67 111 100 101 39 62 84 97 108 107 32 73 110 32 67 111 100 101 60 47 97 62 34 59&#39;;<br />
$code = unobfuscate($code);<br />
eval($code);</code></p>
<p>This produces the following output.</p>
<p><code class="html">&lt;a href=&#39;http://www.talkincode.com/&#39; title&#39;Talk In Code&#39;&gt;Talk In Code&lt;/a&gt;</code></p>
<p>Beware that doing this sort of thing will probably slow down your application, especially if you try to eval() a large block of code.   A single link like this is probably as far as I would personally go as there are much better ways of verifying that a piece of software is properly licensed.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.talkincode.com/hide-and-unhide-code-with-php-1168.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>Print Array Without Trailing Commas In PHP</title>
		<link>http://www.talkincode.com/print-array-without-trailing-commas-in-php-1165.html</link>
		<comments>http://www.talkincode.com/print-array-without-trailing-commas-in-php-1165.html#comments</comments>
		<pubDate>Fri, 24 Apr 2009 09:10:08 +0000</pubDate>
		<dc:creator>Tech</dc:creator>
		
		<category><![CDATA[PHP Arrays]]></category>

		<category><![CDATA[array]]></category>

		<category><![CDATA[array_filter]]></category>

		<category><![CDATA[blank]]></category>

		<category><![CDATA[commas]]></category>

		<category><![CDATA[function]]></category>

		<category><![CDATA[implode]]></category>

		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.talkincode.com/?p=1165</guid>
		<description><![CDATA[I have previously talked about Removing commas from the end of strings, but it is also possible to use the implode() function to do the same sort of thing.  
implode() takes two parameters, the separator and the array, and returns a string with each array item separated with the separator.  The following example [...]]]></description>
			<content:encoded><![CDATA[<p>I have previously talked about <a href="http://www.talkincode.com/delete-trailing-commas-in-php-1120.html" title="Removing commas from the end of strings">Removing commas from the end of strings</a>, but it is also possible to use the implode() function to do the same sort of thing.  </p>
<p>implode() takes two parameters, the separator and the array, and returns a string with each array item separated with the separator.  The following example shows how this function works.</p>
<p><code class="php">$array = array(1,2,3,4,5,6);<br />
$list = implode(&#39;,&#39;, $array);</code></p>
<p>The $list variable will now contain the string &quot;1,2,3,4,5,6&quot;. However, things tend to become messy again when you have an array with empty items in it.</p>
<p><code class="php">$array = array(1,2,3,4,5,6,&#39;&#39;,&#39;&#39;,&#39;&#39;);<br />
$list = implode(&#39;,&#39;, $array);</code></p>
<p>The $list variable will now contain the string &quot;1,2,3,4,5,6,,&quot;.  So to solve this issue we need to use the array_filter() function to clear out any blank array items before passing the output to the implode() function.  The following example shows this in action.</p>
<p><code class="php">$array = array(1,2,3,4,5,6,&#39;&#39;,&#39;&#39;,&#39;&#39;);<br />
$list = implode(&#39;,&#39;, array_filter($array));</code></p>
<p>The $list variable will now contain the string &quot;1,2,3,4,5,6&quot;, which is the string we are looking for.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.talkincode.com/print-array-without-trailing-commas-in-php-1165.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>PHP Array Of Australian States</title>
		<link>http://www.talkincode.com/php-array-of-australian-states-1160.html</link>
		<comments>http://www.talkincode.com/php-array-of-australian-states-1160.html#comments</comments>
		<pubDate>Thu, 23 Apr 2009 12:44:09 +0000</pubDate>
		<dc:creator>Tech</dc:creator>
		
		<category><![CDATA[PHP Arrays]]></category>

		<category><![CDATA[array]]></category>

		<category><![CDATA[australian]]></category>

		<category><![CDATA[PHP]]></category>

		<category><![CDATA[states]]></category>

		<guid isPermaLink="false">http://www.talkincode.com/?p=1160</guid>
		<description><![CDATA[Use the following array to print out a list of Australian states.
$australian_states = array(
&#160;&#160;&#160;&#160;&#34;NSW&#34;=&#62;&#34;New South Wales&#34;,
&#160;&#160;&#160;&#160;&#34;VIC&#34;=&#62;&#34;Victoria&#34;,
&#160;&#160;&#160;&#160;&#34;QLD&#34;=&#62;&#34;Queensland&#34;,
&#160;&#160;&#160;&#160;&#34;TAS&#34;=&#62;&#34;Tasmania&#34;,
&#160;&#160;&#160;&#160;&#34;SA&#34;=&#62;&#34;South Australia&#34;,
&#160;&#160;&#160;&#160;&#34;WA&#34;=&#62;&#34;Western Australia&#34;,
&#160;&#160;&#160;&#160;&#34;NT&#34;=&#62;&#34;Northern Territory&#34;,
&#160;&#160;&#160;&#160;&#34;ACT&#34;=&#62;&#34;Australian Capital Terrirory&#34;);
]]></description>
			<content:encoded><![CDATA[<p>Use the following array to print out a list of Australian states.</p>
<p><code class="php">$australian_states = array(<br />
&nbsp;&nbsp;&nbsp;&nbsp;&quot;NSW&quot;=&gt;&quot;New South Wales&quot;,<br />
&nbsp;&nbsp;&nbsp;&nbsp;&quot;VIC&quot;=&gt;&quot;Victoria&quot;,<br />
&nbsp;&nbsp;&nbsp;&nbsp;&quot;QLD&quot;=&gt;&quot;Queensland&quot;,<br />
&nbsp;&nbsp;&nbsp;&nbsp;&quot;TAS&quot;=&gt;&quot;Tasmania&quot;,<br />
&nbsp;&nbsp;&nbsp;&nbsp;&quot;SA&quot;=&gt;&quot;South Australia&quot;,<br />
&nbsp;&nbsp;&nbsp;&nbsp;&quot;WA&quot;=&gt;&quot;Western Australia&quot;,<br />
&nbsp;&nbsp;&nbsp;&nbsp;&quot;NT&quot;=&gt;&quot;Northern Territory&quot;,<br />
&nbsp;&nbsp;&nbsp;&nbsp;&quot;ACT&quot;=&gt;&quot;Australian Capital Terrirory&quot;);</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.talkincode.com/php-array-of-australian-states-1160.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>PHP Array Of Canadian States</title>
		<link>http://www.talkincode.com/php-array-of-canadian-states-1158.html</link>
		<comments>http://www.talkincode.com/php-array-of-canadian-states-1158.html#comments</comments>
		<pubDate>Thu, 23 Apr 2009 12:42:41 +0000</pubDate>
		<dc:creator>Tech</dc:creator>
		
		<category><![CDATA[PHP Arrays]]></category>

		<category><![CDATA[array]]></category>

		<category><![CDATA[canadian]]></category>

		<category><![CDATA[PHP]]></category>

		<category><![CDATA[states]]></category>

		<guid isPermaLink="false">http://www.talkincode.com/?p=1158</guid>
		<description><![CDATA[Use the following array to print out a list of Canadian states, also know as provinces.
$canadian_states = array(&#160;
&#160;&#160;&#160;&#160;&#34;BC&#34;=&#62;&#34;British Columbia&#34;,&#160;
&#160;&#160;&#160;&#160;&#34;ON&#34;=&#62;&#34;Ontario&#34;,&#160;
&#160;&#160;&#160;&#160;&#34;NL&#34;=&#62;&#34;Newfoundland and Labrador&#34;,&#160;
&#160;&#160;&#160;&#160;&#34;NS&#34;=&#62;&#34;Nova Scotia&#34;,&#160;
&#160;&#160;&#160;&#160;&#34;PE&#34;=&#62;&#34;Prince Edward Island&#34;,&#160;
&#160;&#160;&#160;&#160;&#34;NB&#34;=&#62;&#34;New Brunswick&#34;,&#160;
&#160;&#160;&#160;&#160;&#34;QC&#34;=&#62;&#34;Quebec&#34;,&#160;
&#160;&#160;&#160;&#160;&#34;MB&#34;=&#62;&#34;Manitoba&#34;,&#160;
&#160;&#160;&#160;&#160;&#34;SK&#34;=&#62;&#34;Saskatchewan&#34;,&#160;
&#160;&#160;&#160;&#160;&#34;AB&#34;=&#62;&#34;Alberta&#34;,&#160;
&#160;&#160;&#160;&#160;&#34;NT&#34;=&#62;&#34;Northwest Territories&#34;,&#160;
&#160;&#160;&#160;&#160;&#34;NU&#34;=&#62;&#34;Nunavut&#34;
&#160;&#160;&#160;&#160;&#34;YT&#34;=&#62;&#34;Yukon Territory&#34;);
Here is the same array, but with the French versions of the states.
$canadian_states = array(&#160;
&#160;&#160;&#160;&#160;&#34;AB&#34;=&#62;&#34;Alberta&#34;
&#160;&#160;&#160;&#160;&#34;BC&#34;=&#62;&#34;Colombie-Britannique&#34;
&#160;&#160;&#160;&#160;&#34;MB&#34;=&#62;&#34;Manitoba&#34;
&#160;&#160;&#160;&#160;&#34;NB&#34;=&#62;&#34;Nouveau-Brunswick&#34;
&#160;&#160;&#160;&#160;&#34;NL&#34;=&#62;&#34;Terre-Neuve-et-Labrador&#34;
&#160;&#160;&#160;&#160;&#34;NS&#34;=&#62;&#34;Nouvelle-&#201;cosse&#34;
&#160;&#160;&#160;&#160;&#34;NT&#34;=&#62;&#34;Territoires du Nord-Ouest&#34;
&#160;&#160;&#160;&#160;&#34;NU&#34;=&#62;&#34;Nunavut&#34;
&#160;&#160;&#160;&#160;&#34;ON&#34;=&#62;&#34;Ontario&#34;
&#160;&#160;&#160;&#160;&#34;PE&#34;=&#62;&#34;&#206;le-du-Prince-&#201;douard&#34;
&#160;&#160;&#160;&#160;&#34;QC&#34;=&#62;&#34;Qu&#233;bec&#34;
&#160;&#160;&#160;&#160;&#34;SK&#34;=&#62;&#34;Saskatchewan&#34;
&#160;&#160;&#160;&#160;&#34;YT&#34;=&#62;&#34;Yukon&#34;);
]]></description>
			<content:encoded><![CDATA[<p>Use the following array to print out a list of Canadian states, also know as provinces.</p>
<p><code class="php">$canadian_states = array(&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&quot;BC&quot;=&gt;&quot;British Columbia&quot;,&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&quot;ON&quot;=&gt;&quot;Ontario&quot;,&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&quot;NL&quot;=&gt;&quot;Newfoundland and Labrador&quot;,&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&quot;NS&quot;=&gt;&quot;Nova Scotia&quot;,&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&quot;PE&quot;=&gt;&quot;Prince Edward Island&quot;,&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&quot;NB&quot;=&gt;&quot;New Brunswick&quot;,&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&quot;QC&quot;=&gt;&quot;Quebec&quot;,&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&quot;MB&quot;=&gt;&quot;Manitoba&quot;,&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&quot;SK&quot;=&gt;&quot;Saskatchewan&quot;,&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&quot;AB&quot;=&gt;&quot;Alberta&quot;,&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&quot;NT&quot;=&gt;&quot;Northwest Territories&quot;,&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&quot;NU&quot;=&gt;&quot;Nunavut&quot;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&quot;YT&quot;=&gt;&quot;Yukon Territory&quot;);</code></p>
<p>Here is the same array, but with the French versions of the states.</p>
<p><code class="php">$canadian_states = array(&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&quot;AB&quot;=&gt;&quot;Alberta&quot;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&quot;BC&quot;=&gt;&quot;Colombie-Britannique&quot;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&quot;MB&quot;=&gt;&quot;Manitoba&quot;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&quot;NB&quot;=&gt;&quot;Nouveau-Brunswick&quot;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&quot;NL&quot;=&gt;&quot;Terre-Neuve-et-Labrador&quot;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&quot;NS&quot;=&gt;&quot;Nouvelle-&Eacute;cosse&quot;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&quot;NT&quot;=&gt;&quot;Territoires du Nord-Ouest&quot;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&quot;NU&quot;=&gt;&quot;Nunavut&quot;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&quot;ON&quot;=&gt;&quot;Ontario&quot;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&quot;PE&quot;=&gt;&quot;&Icirc;le-du-Prince-&Eacute;douard&quot;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&quot;QC&quot;=&gt;&quot;Qu&eacute;bec&quot;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&quot;SK&quot;=&gt;&quot;Saskatchewan&quot;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&quot;YT&quot;=&gt;&quot;Yukon&quot;);</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.talkincode.com/php-array-of-canadian-states-1158.html/feed</wfw:commentRss>
		</item>
	</channel>
</rss>
