Awhile back I created a basic webmaster utility script called Easy Cell Code Generator which helped find easy to type cell phone numbers, but what if you had a domain and wanted to convert it out the other way? I decided to whip up some quick code to do just that:

Short domain:
mughd.com

Typed into cell phone / portable device as:
6-88-4-44-3 [char] 222-666-6

I used [char] because how to type in a period can vary depending on the device. This counts as only one character. That’s a total of 15 characters to type in a five character domain.

Let’s create a script to automatically perform the same checks. We’ll start with a 26 character array to define the code for each character.

< ?php
$test_in = 'mughd.com'; // change to domain you want to use
$portable_matrix = array('a'=>2,’b'=>22,’c'=>222,’d'=>3,’e'=>33,’f'=>333,
‘g’=>4, ‘h’=>44, ‘i’=>444, ‘j’=>5, ‘k’=>55, ‘l’=>555, ‘m’=>6, ‘n’=>66, ‘o’=>666, ‘p’=>7, ‘q’=>77, ‘r’=>777, ’s’=>7777, ‘t’=>8, ‘u’=>88, ‘v’=>888, ‘w’=>9, ‘x’=>99, ‘y’=>999, ‘z’=>9999);
$length = strlen($test_in);
$char_code = ”;
if($length>1) {
for($i=0;$i< $length;$i++) {
// get character
$character = strtolower(substr($test_in,$i,1));
if(preg_match("|[a-z]|",$character)) {
$char_code .= $portable_matrix[$character];
$char_no_space .= $portable_matrix[$character] . '-';
$new_len = $new_len + strlen($portable_matrix[$character]);

} else {
$char_code .= '[code]';
$char_no_space .= '[code]-';
$new_len = $new_len + 1;
}
print "$character -> $char_no_space
“;
}
$char_no_space = substr($char_no_space,0,-1);
print “<hr /><font color=’green’>$test_in</font> [phone characters: $new_len -> domain characters: $length]
CHAR CODE (without spaces): $char_code
CHAR CODE: $char_no_space“;
}
?>

This will produce output that looks like this:

m -> 6-
u -> 6-88-
g -> 6-88-4-
h -> 6-88-4-44-
d -> 6-88-4-44-3-
. -> 6-88-4-44-3-[code]-
c -> 6-88-4-44-3-[code]-222-
o -> 6-88-4-44-3-[code]-222-666-
m -> 6-88-4-44-3-[code]-222-666-6-

mughd.com [phone characters: 15 -> domain characters: 9]
CHAR CODE (without spaces): 6884443[code]2226666
CHAR CODE: 6-88-4-44-3-[code]-222-666-6

By changing the $test_in to a different domain you can test different codes. I created a form version where you can just enter in the url at TD Scripts in the Webmaster Utilities area here: http://www.tdscripts.com/webmaster_utilities/easy_cell2.php

Argh, it seems like the code snippet plugin is eating some of the code again. For the HTML portion view the source code of this page.