2017 © Pedro Peláez
 

library ordinal-number

Converts numbers to a human readable ordinal form eg. 'first', 'second' or even 'Three thousand five hundred sixty first'

image

martinjoiner/ordinal-number

Converts numbers to a human readable ordinal form eg. 'first', 'second' or even 'Three thousand five hundred sixty first'

  • Monday, December 19, 2016
  • by martinjoiner
  • Repository
  • 1 Watchers
  • 4 Stars
  • 4,417 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 5 Versions
  • 1 % Grown

The README.md

Ordinal Number

A PHP package for converting numbers to a human readable sentence of it's ordinal form eg. 'first', 'second' or even 'Three thousand five hundred and sixty first', (*1)

Latest release supports numbers in the range 1 - 9999., (*2)

Installation

Recomended installation via Composer:, (*3)

    composer require martinjoiner/ordinal-number

See library page on Packagist https://packagist.org/packages/martinjoiner/ordinal-number, (*4)

Usage example

    // Tell our code to use the namespace
    use MartinJoiner\OrdinalNumber\OrdinalNumber;

    // The following line will output 'three hundred seventy eighth'
    print OrdinalNumber::convert( 378 );

    // The following line will output 'three hundred and seventy eighth'
    print OrdinalNumber::convert( 378, true );

    // The following line will output 'Three hundred and seventy eighth' (notice capitalised)
    print OrdinalNumber::convert( 378, true, true );

convert() method parameters

Required parameters

  • num {integer} A number to be converted (in the range of 1 - 9999)

Optional parameters

  • appendAnd {boolean} - Default: false - Places the word 'and' before the final 2 parts if number above 101 or higher (eg. One hundred and first). Added to support both American and European versions of English language.
  • titleCase {boolean} - Default: false - Capitalises the first letter

To see some working examples simply run index.php, (*5)

Testing

Tests are written in PHPUnit https://phpunit.de/, (*6)

    phpunit --bootstrap vendor/autoload.php tests/OrdinalNumberTest

The Versions

19/12 2016

dev-master

9999999-dev

Converts numbers to a human readable ordinal form eg. 'first', 'second' or even 'Three thousand five hundred sixty first'

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

number english ordinal

19/12 2016

v1.0.0

1.0.0.0

Converts numbers to a human readable ordinal form eg. 'first', 'second' or even 'Three thousand five hundred sixty first'

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

number english ordinal

19/12 2016

0.3.0

0.3.0.0

Converts numbers to a human readable ordinal form eg. 'first', 'second' or even 'Three thousand five hundred sixty first'

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

number english ordinal

06/02 2016

0.2.0

0.2.0.0

Converts numbers to a human readable ordinal form eg. 'first', 'second' or even 'Three thousand five hundred sixty first'

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

number english ordinal

06/02 2016

0.1.1

0.1.1.0

Converts numbers to a human readable ordinal form eg. 'first', 'second' or even 'Three thousand five hundred sixty first'

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

number english ordinal