Recommended:

  • phpclasses.org
  • jsclasses.org
  • jsmag.com
  • siteapps.com
  • View our reviews on Hot Scripts
  • JS Tutorial
  • scripts.com
  • securesignup.com




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.

Contents

Download

Example codes

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

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

//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()
Description

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

set_idiom("en")

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()
Description

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

Returns

Return true if word is valid or false if invalid

Latest changes

None for now

Awards

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


You may also be interested in:

Powered by BlogAlike.com

blog comments powered by Disqus