jaredhowland / new-base-60
PHP库,用于将十进制数字转换为新的60进制以及反向转换
v1.1.0
2023-04-14 06:23 UTC
Requires
- php: >=7.2
This package is auto-updated.
Last update: 2024-09-14 09:30:12 UTC
README
新的60进制是一种由Tantek Çelik创建的仅使用ASCII数字和字母的60进制数制系统(更多信息请参阅http://tantek.pbworks.com/w/page/19402946/NewBase60)。
此PHP库在60进制和十进制之间进行转换。
安装
使用Composer
composer require jaredhowland/new-base-60
或者在您的composer.json
文件中添加以下内容
"require": {
"jaredhowland/new-base-60": "^1.0"
}
否则,只需将文件包含到您的项目中
require_once 'path/to/src/NewBase60.php';
用法
示例用法
<?php
use NewBase60\NewBase60;
require_once 'src/NewBase60.php';
echo NewBase60::toNewBase60('20200108'); // Output: 1ZX8U
echo NewBase60::toBase10('1ZX8U'); // Output: 20200108
// For the next methods, the second argument is the length of the padding to include
// Based on PHP’s built-in `str_pad`
echo NewBase60::toNewBase60WithLeadingZeroes('20200108', 10); // Output: 000001ZX8U
echo NewBase60::toBase10WithLeadingZeroes('1ZX8U', 10); // Output: 0020200108
这就完成了。这些是这个库中包含的唯一4个函数。非常基础,但完整,支持新的60进制。有关为什么在项目中使用或不想使用新的60进制的信息,请参阅http://tantek.pbworks.com/w/page/19402946/NewBase60。