nomeaning.net's improved Phone Number Translator

0) && ($places < 2) ) { echo "C'mon, try a number with a few digits at least!
"; } else if ( $places > MAX_PLACES ) { echo " What are you trying to do with so many digits, give me a fit?
\n"; $phone_number = substr($phone_number, 0, MAX_PLACES); } ?>

You're testing my newer, harder-working phone number translator.  I'm still trying to find out the most useful way to display the matches, and the way it works my change at any time.  Only words of three or more letters are currently matched, and no pronouncable but misspelled combinations like LUV or FUZ will be matched until/unless I create a custom dictionary.

If you have any comments, please email me.

'> Enter 0 ) ? 'another' : 'a' ?> number (from 2 to digits long) to try:  

(Remember, the numbers one and zero do not represent letters of the alphabet!)

Don't look for words (show every single combination, like our old phone number translator):


0 ) { $size = 15; if ( $places > 2 ) { echo " Here are the alphabetic combinations made by the number $number"; if ( $show_all ) { echo ".
\n"; } else { echo " which contain a dictionary word.
\n"; } } // end if // create the keypad matrix $letter = array( 0=>array('#'), 1=>array('#'), 2=>array('a','b','c'), 3=>array('d','e','f'), 4=>array('g','h','i'), 5=>array('j','k','l'), 6=>array('m','n','o'), 7=>array('p','q','r','s'), 8=>array('t','u','v'), 9=>array('w','y','x','z') ); //echo "
";
  //var_dump($letters);
  //echo "
"; // index keeps track of which letter we're on for each digit $index = array(); // keeps track of positions of non-digits $non_digits = array(); // count the number of digits, initialize the index array $digits = 0; for ( $place = 0; $place < $places; $place++ ) { $index[$place] = 0; $dig = $number{$place};//substr($number, $place, 1); // echo $dig."
"; if ( ($dig >= '0') && ($dig <= '9') ) { $max[$place] = count($letter[$dig]) - 1; $digits++; } else { $non_digit[$place] = $dig; } } // end for // var_dump($non_digit); // return; //echo "
";
  //var_dump($index);
  //var_dump($max);
  //echo "
"; $rows = 0; $combos = 0; $lastPlace = $places - 1; // set up pspell $pspell_config = pspell_config_create('en'); pspell_config_runtogether($pspell_config, false); $psc = pspell_new_config($pspell_config); // echo pspell_check($psc, "deg"); // return; $matches = 0; // create all the combinations while ( $index[0] <= $max[0] ) { for ( $place = 0; $place < $places; $place++ ) { $dig = $number{$place};//substr($number, $place, 1); if ( ($dig >= '0') && ($dig <= '9') ) { $spstr .= $letter[$dig][$index[$place]]; // for spelling $str .= $letter[$dig][$index[$place]]; // echo $letter[$dig][$index[$place]]; } else { $str .= $dig; // echo $dig; } } // end for $index[$lastPlace]++; // "roll over" the places if necessary $i = $lastPlace; while ( ($index[$i] > $max[$i]) && ($i > 0) ) { $index[$i] = 0; $i--; if ( $i >= 0 ) { $index[$i]++; } } // end while if ( $show_all ) { $combo[$combos] = strtoupper($str); } else { // check for matching words of MIN_WORD_LEN or more letters for ( $i = 0; $i <= ($digits - MIN_WORD_LEN); $i++ ) // for ( $i = 0; !$found_match && ($i <= ($digits - MIN_WORD_LEN)); $i++ ) { for ( $len = MIN_WORD_LEN; ($i + $len) <= $digits; $len++ ) { // echo "i=$i, len=$len: ".substr($spstr, $i, $len)."
\n"; if ( pspell_check($psc, substr($spstr, $i, $len)) ) { $bstart = $i; $blen = $len; /* // make the matching word uppercase $spstr = substr($spstr, 0, $i) .strtoupper(substr($spstr, $i, $len)) .substr($spstr, ($i + $len)); */ $temp = $spstr; if ( $places != $digits ) { // re-insert any non-digits in the user-supplied string foreach ( $non_digit as $pos=>$char ) { if ( $pos <= $bstart ) { $bstart++; } else if ( $pos < ($i + $len) ) { $blen++; } $temp = substr($temp, 0, $pos).$char.substr($temp, $pos); } // end foreach } // end if // make the matching word bold $match[$matches] = substr($temp, 0, $bstart).'' .strtoupper(substr($temp, $bstart, $blen)).'' .substr($temp, ($bstart + $blen)); // echo $match[$matches]; // return; $matches++; } // end if } // end for } // end for } unset($spstr); unset($str); $combos++; } // end while // var_dump(pspell_suggest($psc, 'ride')); echo "\n"; $row = 0; $items = ($show_all ? $combos : $matches ); for ( $i = 0; $i < $items; ) { if ( $i % COLUMNS == 0 ) { $bgcolor = (($row % 2 == 0) ? 'aaeeaa' : 'ddeedd'); echo "\n"; $row ++; } if ( $show_all ) { echo ""; } else { echo ""; } $i++; if ( $i % COLUMNS == 0 ) { echo "\n"; } } // end for // make sure the last row has COLUMNS columns if ( $i % COLUMNS != 0 ) { while ( $i % COLUMNS != 0 ) { echo ""; $i++; } echo "\n"; } echo "
{$combo[$i]}{$match[$i]}
 
"; if ( $show_all ) { echo "

$combos combinations shown.

"; } else { echo "

$matches combinations shown out of a total of $combos for this number.

"; } if ( strpos($number, '0') || strpos($number, '1') ) { echo "

This number contains zeros or ones, which have no letter equivalent, and are shown as '#' in the list

\n"; } if ( strpos($number, '7') || strpos($number, '9') ) { echo "

Note that 'Q' and 'Z' do not exist on most older telephones!

\n"; } } // end if - else ?>