- strtoupper: documentation ( source)
- rand: documentation ( source)
<?php
function generateTestingCenterNumber()
{
$nation = strtoupper('de');
// created schon da?
$zulassung = new DateTime('now');
$jahr = $zulassung->format('Y');
#$qmonat = $this->crossfoot($zulassung->format('n'));
$tagdesjahres = $zulassung->format('z');
$qtimestamp = crossfoot($zulassung->format('U'));
return $nation.'TC'.$jahr.$tagdesjahres.$qtimestamp.rand(1000, 9999);
}
function crossfoot( $digits )
{
// Typcast falls Integer uebergeben
$strDigits = ( string ) $digits;
for( $intCrossfoot = $i = 0; $i < strlen ( $strDigits ); $i++ )
{
$intCrossfoot += $strDigits{$i};
}
return $intCrossfoot;
}
echo generateTestingCenterNumber();