<?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: PHP Luhn modulus implementation</title>
	<atom:link href="http://blog.planzero.org/2009/08/luhn-modulus-implementation-php/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.planzero.org/2009/08/luhn-modulus-implementation-php/</link>
	<description>Mind dump</description>
	<lastBuildDate>Sun, 05 Sep 2010 08:56:33 +0100</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Duam</title>
		<link>http://blog.planzero.org/2009/08/luhn-modulus-implementation-php/comment-page-1/#comment-1780</link>
		<dc:creator>Duam</dc:creator>
		<pubDate>Wed, 24 Mar 2010 16:42:40 +0000</pubDate>
		<guid isPermaLink="false">http://blog.planzero.org/?p=250#comment-1780</guid>
		<description>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;    http://www.duam.com.mx   &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;</description>
		<content:encoded><![CDATA[<p>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;    <a href="http://www.duam.com.mx" rel="nofollow">http://www.duam.com.mx</a>   &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Trink</title>
		<link>http://blog.planzero.org/2009/08/luhn-modulus-implementation-php/comment-page-1/#comment-1768</link>
		<dc:creator>Trink</dc:creator>
		<pubDate>Tue, 24 Nov 2009 00:29:49 +0000</pubDate>
		<guid isPermaLink="false">http://blog.planzero.org/?p=250#comment-1768</guid>
		<description>Wow my bad, I just copied and pasted my code and didn&#039;t pay attention to the greater than and less than signs.  It should actually look like this:
function luhn_validate($input, $mod5 = false){
$total = 0;
settype($input,&#039;string&#039;);
$length = strlen((string)$input);
$parity = $length % 2;
for($i = 0;$i &lt; $length;$i++) $total += ($i % 2 === $parity ? (($x = (int)$input[$i] * 2) &gt; 9 ? $x - 9 : $x) : (int)$input[$i]);
return (($total % ((boolean)$mod5 ? 5 : 10)) == 0);
}</description>
		<content:encoded><![CDATA[<p>Wow my bad, I just copied and pasted my code and didn&#8217;t pay attention to the greater than and less than signs.  It should actually look like this:<br />
function luhn_validate($input, $mod5 = false){<br />
$total = 0;<br />
settype($input,&#8217;string&#8217;);<br />
$length = strlen((string)$input);<br />
$parity = $length % 2;<br />
for($i = 0;$i &lt; $length;$i++) $total += ($i % 2 === $parity ? (($x = (int)$input[$i] * 2) &gt; 9 ? $x &#8211; 9 : $x) : (int)$input[$i]);<br />
return (($total % ((boolean)$mod5 ? 5 : 10)) == 0);<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Trink</title>
		<link>http://blog.planzero.org/2009/08/luhn-modulus-implementation-php/comment-page-1/#comment-1767</link>
		<dc:creator>Trink</dc:creator>
		<pubDate>Tue, 24 Nov 2009 00:26:50 +0000</pubDate>
		<guid isPermaLink="false">http://blog.planzero.org/?p=250#comment-1767</guid>
		<description>function luhn_validate($input, $mod5 = false){
    $total = 0;
    settype($input,&#039;string&#039;);
    $length = strlen((string)$input);
    $parity = $length % 2;
    for($i = 0;$i  9 ? $x - 9 : $x) : (int)$input[$i]);
    return (($total % ((boolean)$mod5 ? 5 : 10)) == 0);
}</description>
		<content:encoded><![CDATA[<p>function luhn_validate($input, $mod5 = false){<br />
    $total = 0;<br />
    settype($input,&#8217;string&#8217;);<br />
    $length = strlen((string)$input);<br />
    $parity = $length % 2;<br />
    for($i = 0;$i  9 ? $x &#8211; 9 : $x) : (int)$input[$i]);<br />
    return (($total % ((boolean)$mod5 ? 5 : 10)) == 0);<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: chanthu</title>
		<link>http://blog.planzero.org/2009/08/luhn-modulus-implementation-php/comment-page-1/#comment-1560</link>
		<dc:creator>chanthu</dc:creator>
		<pubDate>Fri, 18 Sep 2009 07:48:05 +0000</pubDate>
		<guid isPermaLink="false">http://blog.planzero.org/?p=250#comment-1560</guid>
		<description>Nice one.....</description>
		<content:encoded><![CDATA[<p>Nice one&#8230;..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: chanthu</title>
		<link>http://blog.planzero.org/2009/08/luhn-modulus-implementation-php/comment-page-1/#comment-1559</link>
		<dc:creator>chanthu</dc:creator>
		<pubDate>Fri, 18 Sep 2009 07:47:37 +0000</pubDate>
		<guid isPermaLink="false">http://blog.planzero.org/?p=250#comment-1559</guid>
		<description>thanks for the algorithm....</description>
		<content:encoded><![CDATA[<p>thanks for the algorithm&#8230;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alix Axel</title>
		<link>http://blog.planzero.org/2009/08/luhn-modulus-implementation-php/comment-page-1/#comment-1474</link>
		<dc:creator>Alix Axel</dc:creator>
		<pubDate>Sun, 13 Sep 2009 23:57:24 +0000</pubDate>
		<guid isPermaLink="false">http://blog.planzero.org/?p=250#comment-1474</guid>
		<description>Thanks for the reference, here is a function to generate a Luhn checksum:

function Luhn($number, $iterations = 1)
{
	while ($iterations-- &gt;= 1)
	{
		$stack = 0;
		$number = str_split(strrev($number), 1);

		foreach ($number as $key =&gt; $value)
		{
			if ($key % 2 == 0)
			{
				$value = array_sum(str_split($value * 2, 1));
			}

			$stack += $value;
		}

		$stack %= 10;

		if ($stack != 0)
		{
			$stack -= 10;
		}

		$number = implode(&#039;&#039;, array_reverse($number)) . abs($stack);
	}

	return $number;
}

A validation that uses this function can also be easily coded.</description>
		<content:encoded><![CDATA[<p>Thanks for the reference, here is a function to generate a Luhn checksum:</p>
<p>function Luhn($number, $iterations = 1)<br />
{<br />
	while ($iterations&#8211; &gt;= 1)<br />
	{<br />
		$stack = 0;<br />
		$number = str_split(strrev($number), 1);</p>
<p>		foreach ($number as $key =&gt; $value)<br />
		{<br />
			if ($key % 2 == 0)<br />
			{<br />
				$value = array_sum(str_split($value * 2, 1));<br />
			}</p>
<p>			$stack += $value;<br />
		}</p>
<p>		$stack %= 10;</p>
<p>		if ($stack != 0)<br />
		{<br />
			$stack -= 10;<br />
		}</p>
<p>		$number = implode(&#8221;, array_reverse($number)) . abs($stack);<br />
	}</p>
<p>	return $number;<br />
}</p>
<p>A validation that uses this function can also be easily coded.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
