Convert Dell service tags and express service tags with PHP
By: Daniel

I was given the task at my real job of creating some code to find the service tag from the express service tag of Dell laptops. We only had recorded the express service tag for the 100+ laptops and needed to have the service tag in a project we were working on. I was given some very basic information about the relationship between the two and came up with the following code. With this code you can convert service tags into express service tags and the other way around. It uses a base 36 style formating.

<?php
function convertExpress($tag) {
  $index = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','e');
  
  for($i=10; $i>=0; $i--) {
    $digits[$i] = '0';
    for($k=1; $k<=36; $k++) {
      $tmp = (pow(36, $i)) * $k;
      $tmp2 = $tag - $tmp;
      if($tmp2 < 0) {
        $tmp = (pow(36, $i)) * ($k-1);
        $digits[$i] = $index[$k-1];
        $tag -= $tmp;
        break;
      }
      
      if($tmp2 == 0) {
        $digits[$i] = $index[$k];
        $tag -= $tmp;
        break;
      }   
    }
  }
  $leading = 1;
  foreach($digits as $digit) {
    /*if($digit != '0') {
      $num .= $digit;
    }*/
    if($leading) {
      if($digit != '0') {
        $leading = 0;
        $num .= $digit;
      }
    } else {
      $num .= $digit;
    }
  }
  return $num;
}
?>

To use this code you could use:

<?php
echo convertExpress('(YOUR EXPRESS SERVICE TAG HERE');
?>

Make sure you only use numbers this field.

To get the express service tag from the service tag use the following function:

<?php
function convertTag($tag) {
  $tag = strtoupper($tag);
  $index = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
  $count = strlen($tag);
  $count2 = $count - 1;
  for($i=0; $i<$count; $i++) {
    $digits[$count2] = substr($tag, $i, 1);
    $count2--;
  }
  $numb = 0;
  for($i=0; $i<count($digits); $i++) {
    if($i==0) {
      $m = 1;
    } else {
      $m = pow(36, $i);
    }
    $key = array_keys($index, $digits[$i]);
    $tmp = ($m * $key[0]);
    $numb += $tmp;
  } 
  return $numb;
}
?>

To use this code you can use:

<?php
echo convertTag('(YOUR SERVICE TAG HERE)');
?>
1 Star2 Stars3 Stars4 Stars5 Stars (10 votes, average: 3.90 out of 5)
Loading ... Loading ...

7 Responses to “Convert Dell service tags and express service tags with PHP”

  1. Johan Desmedt Says:

    I’ve no idea why you needed to search how to convert those codes from Dell. Prmier users from Dell can get several programs for free (depending your purpuse, some have a database with every service tag so they get a program to read the database and writes in a second field the express code, others have other needs). As IT & ICT experts we know that a is not equal to A! You said that you got the task to create some code etc…. I got the convertion algorith in a few seconds from Dell, writing the C program took me maybe 30 minutes from scratch till final release, I’m curious how much time you needed for your whole project?

  2. Daniel Says:

    I should have thought to call Dell and ask for the conversion but did not. It took me maybe 1 hour to figure things out.

  3. Ward Says:

    Johan,

    Was all of that really necessary?

    Daniel,

    Thanks for the script. Thankful to have found it for a similar project, as I’ve yet to find the Dell program that I can download to get the S/T of a system, and Dell’s Premier website seems to be less than fully functional more than once a week. Now, I can stop searching!

    Cheers,
    Ward

  4. Rod Says:

    @Johan: If your coding is on par with your typing or grammar. I highly doubt you executed it in 30min.

    @Daniel
    Thank you

  5. Rob Says:

    Could you please elaborate on the implimentation? How do I need to upload this to my site so I can use it? Thanks so much!

  6. Jelle Says:

    I would sent this code back to the programmer; it fails the basic test “is it sensibly commented”. Your comments should make the code easier to understand and explain what you are trying to accomplish and why you did it this way. Mentioning that you are converting a ‘Dell service tag’ to a ‘Dell express service tag’ and vice versa would a good first.

  7. Rodrigo Balibrera Says:

    hey thanks, I was looking for code to do this, I work at Dell and I really needed it even though we got all the tools to find out the express code from service tag this is really helpfull to explain how it is built and also as an offline tool when the systems goes trough an outrage or update. i haven’t test it yet, I normally use VB.NET, I know a little C So I can figure out the code, thnks.

Leave a Reply

geovisitors