PHP Classes
elePHPant
Icontem

PHP Word to Number: Convert a string with amount in words to a number

Recommend this page to a friend!
  Info   View files Documentation   View files View files (11)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2019-11-30 (10 days ago) RSS 2.0 feedNot yet rated by the usersTotal: 52 This week: 18All time: 9,638 This week: 11Up
Version License PHP version Categories
php-word-to-number 1.0The PHP License7PHP 5, Text processing, Finances
Description Author

This package can Convert a string with amount in words to a number.

It can take a text string that has words that express a given amount and parses it to extract the number that it represents.

The package can potentially support processing number strings in multiple languages. Currently it supports converting strings to numbers in English.

  Performance   Level  
Name: Zacchaeus Bolaji <contact>
Classes: 7 packages by
Country: Nigeria Nigeria
Age: ???
All time rank: 377526 in Nigeria Nigeria
Week rank: 4 Up1 in Nigeria Nigeria Up
Innovation award
Innovation award
Nominee: 1x

 

Details

Word To Number

CircleCI Latest Stable Version Total Downloads License Build Status Scrutinizer Code Quality Code Coverage StyleCI

This PHP package allows you convert numbers written in words to integers

Installation

You can install the package via composer:

composer require djunehor/word-to-number

Usage

use Djunehor\Number\WordToNumber;

$wordToNumber = new WordToNumber();
$wordTransformer = $wordToNumber->getWordTransformer();
// you can specify locale via: $wordToNumber->getWordTransformer('en');
$number = $wordTransformer->toNumber($word);

Via Helper

$number = word_to_number($word);
//default locale is en

$number = word_to_number($word, 'yo');
// specify Yoruba locale

Available Locales

|Language|Code|Test| |:--------- | :-----------------: | :------: | |English|en|Yes|

Adding New Locale

  • In Locales directory, create YourLocaleTransformer class that implements WordTransformer
  • Ensure there's a toNumber() method that accepts string and returns int
  • Add YourLocaleTransformer::class to $wordTransformers array in WordToNumber
  • Ensure the class pass tests
  • Update the Readme Available Locales section with your newly added locale
  • Create a Pull Request
  Files folder image Files  
File Role Description
Files folder image.circleci (1 file)
Files folder imagesrc (1 file, 2 directories)
Files folder imagetests (1 file)
Accessible without login Plain text file .scrutinizer.yml Data Auxiliary data
Accessible without login Plain text file .styleci.yml Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  .circleci  
File Role Description
  Accessible without login Plain text file config.yml Data Auxiliary data

  Files folder image Files  /  src  
File Role Description
Files folder imageHelpers (1 file)
Files folder imageLocales (2 files)
  Plain text file WordToNumber.php Class Class source

  Files folder image Files  /  src  /  Helpers  
File Role Description
  Accessible without login Plain text file helpers.php Aux. Auxiliary script

  Files folder image Files  /  src  /  Locales  
File Role Description
  Plain text file EnglishWordTransformer.php Class Class source
  Plain text file WordTransformer.php Class Class source

  Files folder image Files  /  tests  
File Role Description
  Plain text file WordTest.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:52
This week:18
All time:9,638
This week:11Up