mehmetriza/numbery
最新稳定版本:1.0.0
Composer 安装命令:
composer require mehmetriza/numbery
包简介
Php string to number and validation convert function
关键字:
README 文档
README
Php string to number and validation convert function
install
composer require mehmetriza/numbery
Usage
require "vendor/autoload.php"; Numbery::parse("$1.000,00 adam") // string number ->decimal(2,true) // decimal count, optional (true|false) ->decimalSeparator(',') // using decimal operator ->thousandsSeparator('.') // thousand seperator chracter ->prefix('$',true) // prefix chracter, is optional (true|false) ->suffix(' adam',false) // suffix chracter, is optional (true|false) ->convert(); //return double
Example 1
$a = '$123,45 adam'; Numbery::parse($a) ->decimal(2,true) ->decimalSeparator(',') ->thousandsSeparator('.') ->prefix('$',true) ->suffix(' adam',false) ->convert(); // return 123.45 -> double
Example 2
$a = "100.855.555"; Numbery::parse($a) ->decimal(5,true) ->thousandsSeparator('.') ->convert(); // return 100855555 -> double
if you want the return data type integer
$value = int Numbery::parse($a) ->decimal(5,true) ->thousandsSeparator('.') ->convert();
Exceptions
throws an error if it doesn't conform to conditions
new NumericException; new DecimalException; new PrefixException; new SuffixException; new ThousandException;
统计信息
- 总下载量: 8
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-06-19