/*///////////////////////////////////////////////////////////////
ISRC, PHP, 2010-12-10
ISRC = CC-XXX-YY-NNNNN
CC = RU
XXX = COMPANY
YY = YEAR
NNNNN = number
Artix, master@7masterov.ru, icq:53666599, skype:artixmaster
* Error in code? Nothing is perfect!
* Free source for free Linux, use it for free!
* Please, do not remove this comment!
///////////////////////////////////////////////////////////////*/
function genISRC($country='RU',$company='STK',$year=0,$number=0) {
static $n=1;
if ($number>99999) $number=0;
if ($year==0) $year = date('y');
if ($number!=0) $n=$number;
$code=$country.$company.$year.sprintf("%05d",$n++);
return $code;
}
function checkISRC($code) {
if (strlen($code)==12)
if (preg_match('/\d\d\d\d\d\d\d$/',$code))
return true;
return false;
}
$x = genISRC();
echo checkISRC($x)? "$x correct\n" : "$x incorrect!\n";
Справочник алгоритмов v0.05 © 2007-2025 Igor Salnikov aka SunDoctor