• View our reviews on Hot Scripts
  • JS Tutorial

Recent Comments

Powered by Disqus

Back to articles

Spell your phone number

Phone Spell class can generate words that represent dialing for provided phone number. It also calculates word weight in numbers to order found variations starting from most promising ones.

This class uses Pspell extension as default dictionary, but it is possible to extend class for custom dictionary usage.



Example codes

//it could take some time
//measure time
$time = microtime();
$time = explode(" ", $time);
$start = $time[1] + $time[0];

//declaring class instance
$ws = new phone_spell();
echo "<pre>";
//your phone number here
$arr = $ws->get("8004659269");

//end time
$time = microtime();
$time = explode(" ", $time);
$end = $time[1] + $time[0];
$total_time = round(($end - $start), 4);
echo "<p>PHP execution: ".$total_time." seconds.</p>";

Examples in action

Example scripts provided with package in action:

Method list

Create instance

Back to method list

Method namenew phone_spell()

Create class instance

Set letters to numbers

Back to method list

Method nameset_letters($num, $abc)
DescriptionProvide letters for specific number. By default class uses standard scheme as 2 representing a, b and c, 3 representing d, e and f, etc
Input parameters

int $num - number for which letters will be used

array $abc - letters which may replace specified number

Set idiom

Back to method list

Method nameset_idiom($idiom)
DescriptionIf you use multiple idioms for dictionary, like class default Pspell does, then you can provide which idiom to use by specifying idiom identifier.
Input parameters

string $idiom - idiom identifier for dictionary

Input Example


Get errors

Back to method list

Method nameget_errors()
DescriptionReturns array with errors

Get array of possible number/word combinations

Back to method list

Method nameget($number)
DescriptionReturns array of possible number/word combinations from your specified phone number

Extending class

If you want to use custom dicionary, then you'll have to extend this class and override two functions

Dictionary init

Back to method list

Method namedictionary_init()

Initialize dictionary. Do anything you need to do before using dicionary

Check word

Back to method list

Method namedictionary_check($word)
DescriptionCheck if word is valid
Input parameters

string $word - word that needs to be checked


Return true if word is valid or false if invalid

Latest changes

None for now


Phone Spell class was nominated to October Innovation Award, please support it by voting.

You may also be interested in:

Powered by

blog comments powered by Disqus