At times in our systems support roles we need to call/work with DELL while working with any DELL hardware and we need to provide them the Service Tag or Express Service Tag, This Simple PHP script can be used to translate a DELL Service Tag into the Express Service Tag.
<?php
function ExpressServiceTag($service_tag)
{
$val = 0; //our return value
try
{
$szRange = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$aRange = str_split($szRange); //convert range string to array
$sTag = strtoupper($service_tag); //convert service tag to uppercase
$sTag = strrev($sTag ); //reverse the service tag
$aTag = str_split($sTag); //convert service tag to array
$iLen = count($aTag); //get length of array
//loop through each character in the reversed service tag
for ($i=0; $i<$iLen; $i++)
{
$iPos = strpos($szRange, $aTag[$i]); //find position in array of character
$sum = pow(36, $i); //base raised to the power of exp
$val += $iPos * $sum; //add the position * sum
}
}
catch(Exception $e)
{
echo 'Error: ' . $e->getMessage();
}
return $val;
}
$service_tag = "1J94H51";
$express_service_tag = ExpressServiceTag($service_tag);
echo "Express Service Tag: " . $express_service_tag . "<br>";
?>
or if you prefer one line:
echo $express_service_tag = base_convert($service_tag, 36, 10);