2017 © Pedro Peláez
 

library numeral

A PHP library for formatting and manipulating numbers.

image

adampatterson/numeral

A PHP library for formatting and manipulating numbers.

  • Tuesday, October 17, 2017
  • by adampatterson
  • Repository
  • 1 Watchers
  • 2 Stars
  • 5,217 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 9 Versions
  • 14 % Grown

The README.md

Numeral PHP

PHP Composer, (*1)

A PHP library for formatting and manipulating numbers., (*2)

This script is still under development and a PHP clone of Numeral-js by Adam Draper., (*3)

Install from Packagist

composer require adampatterson/numeral

For use in Laravel Views ( Blade files )

Open config/app.php and add Numeral to the aliases array., (*4)

'Numeral'      => Numeral\Numeral::class

{{ \Numeral::number(85193.456)->format('0.00') }}, (*5)

Usage

use Numeral\Numeral;

class SomeController extends Controller
{
    public function myMethod(Numeral $numeral){
        $numeral->number('85193.456')->format()
    }

    // OR

    public function myOtherMethod(){
        Numeral::number('85193.456')->format()
    }
}

Numbers

var_dump(Numeral::number('85193.456')->format()); // 85193
var_dump(Numeral::number('85193.456')->format('0.00')); // 85193.46
var_dump(Numeral::number('85193.456')->format('0,0.00')); // 85,193.46
var_dump(Numeral::number('-85193.00')->format()); // -85193
var_dump(Numeral::number('-85193')->format('0.00')); // -85193.00

Currency

var_dump(Numeral::number('85187993.00')->format('$0,0.00')); // $85,187,993.00
var_dump(Numeral::number('85187993.00')->format('$0,0')); // $85,187,993
var_dump(Numeral::number('$85187993.00')->format('$0.00')); // $85187993.00
var_dump(Numeral::number('85187993.00')->format('$0')); // $85187993

Percentages

var_dump(Numeral::number('-0.43')->format('0%')); // -43%
var_dump(Numeral::number('0.75')->format('0%')); // 75%

Time

var_dump(Numeral::number('25')->format('00:00:00')); // 0:00:25
var_dump(Numeral::number('238')->format('00:00:00')); // 0:03:58
var_dump(Numeral::number('63846')->format('00:00:00')); // 17:44:06

Unformat

Work in progress., (*6)

The Versions

17/10 2017

dev-master

9999999-dev

A PHP library for formatting and manipulating numbers.

  Sources   Download

MIT

by Adam Patterson

time numbers format percentage numerals

23/02 2016

0.0.7

0.0.7.0

A PHP library for formatting and manipulating numbers.

  Sources   Download

MIT

by Adam Patterson

time numbers format percentage numerals

23/02 2016

0.07

0.07.0.0

A PHP library for formatting and manipulating numbers.

  Sources   Download

MIT

by Adam Patterson

time numbers format percentage numerals

17/02 2016

0.0.6

0.0.6.0

A PHP library for formatting and manipulating numbers.

  Sources   Download

MIT

by Adam Patterson

time numbers format percentage numerals

17/02 2016

0.0.5

0.0.5.0

A PHP library for formatting and manipulating numbers.

  Sources   Download

MIT

by Adam Patterson

time numbers format percentage numerals

17/02 2016

0.0.4

0.0.4.0

A PHP library for formatting and manipulating numbers.

  Sources   Download

MIT

by Adam Patterson

time numbers format percentage numerals

16/02 2016

0.0.3

0.0.3.0

A PHP library for formatting and manipulating numbers.

  Sources   Download

MIT

by Adam Patterson

time numbers format percentage numerals

16/02 2016

0.0.2

0.0.2.0

A PHP library for formatting and manipulating numbers.

  Sources   Download

MIT

by Adam Patterson

time numbers format percentage numerals

16/02 2016

0.0.1

0.0.1.0

A PHP library for formatting and manipulating numbers.

  Sources   Download

MIT

by Adam Patterson

time numbers format percentage numerals