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)');
?>
10 Votes | Average: 3.9 out of 510 Votes | Average: 3.9 out of 510 Votes | Average: 3.9 out of 510 Votes | Average: 3.9 out of 510 Votes | Average: 3.9 out of 5 (10 votes, average: 3.9 out of 5)
Loading ... Loading ...
del.icio.us:Convert Dell service tags and express service tags with PHP digg:Convert Dell service tags and express service tags with PHP spurl:Convert Dell service tags and express service tags with PHP wists:Convert Dell service tags and express service tags with PHP simpy:Convert Dell service tags and express service tags with PHP newsvine:Convert Dell service tags and express service tags with PHP blinklist:Convert Dell service tags and express service tags with PHP furl:Convert Dell service tags and express service tags with PHP reddit:Convert Dell service tags and express service tags with PHP fark:Convert Dell service tags and express service tags with PHP blogmarks:Convert Dell service tags and express service tags with PHP Y!:Convert Dell service tags and express service tags with PHP smarking:Convert Dell service tags and express service tags with PHP magnolia:Convert Dell service tags and express service tags with PHP segnalo:Convert Dell service tags and express service tags with PHP

Leave a Reply

eXTReMe Tracker
geovisitors