note 79902 added to function.strrev

From: Date: Tue, 18 Dec 2007 22:30:31 +0000
Subject: note 79902 added to function.strrev
Groups: php.notes 
Request: Send a blank email to php-notes+get-133764@lists.php.net to get a copy of this message
MOD10, Modulus10 or also called LUHN10 will generate a valid check digit. <?php $inv = "34586"; echo $inv . checkdigit($inv); // Outputs 345868 function checkdigit($num) { $sum = 0; $pos = 0; $rev = strrev($num); $len = strlen($num); if ($len % 2 == 0) $len += 1; while ($pos < $len) { $odd = $rev[$pos] * 2; if ($odd > 9) { $odd -= 9; } $sum += $odd; if ($pos != ($len - 2)) { $sum += $rev[$pos +1]; } $pos += 2; } return ((floor($sum/10) + 1) * 10 - $sum) % 10; } ?> ---- Server IP: 62.73.197.23 Probable Submitter: 83.108.112.80 ---- Manual Page -- http://www.php.net/manual/en/function.strrev.php Edit -- https://master.php.net/note/edit/79902 Del: integrated -- https://master.php.net/note/delete/79902/integrated Del: useless -- https://master.php.net/note/delete/79902/useless Del: bad code -- https://master.php.net/note/delete/79902/bad+code Del: spam -- https://master.php.net/note/delete/79902/spam Del: non-english -- https://master.php.net/note/delete/79902/non-english Del: in docs -- https://master.php.net/note/delete/79902/in+docs Del: other reasons-- https://master.php.net/note/delete/79902 Reject -- https://master.php.net/note/reject/79902 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#133764) next »