talmp / phputils

TALMP 工具 php 库

v2.0.5 2023-08-16 00:22 UTC

This package is auto-updated.

Last update: 2024-09-16 02:42:26 UTC


README

phputils 是一个共享工具库

使用方法

use Talmp\Phputils\StrUtil;

// normal case
str_replace([1, 2], [2, 3], '12');                            // '33'
StrUtil::replaceOnce([1, 2], [2, 3], '12');                   // '23'
str_replace(['1', '0'], ['x110x2', 'x010'], 'a1b0c')          // 'ax11x010x2bx010c'
StrUtil::replaceOnce(['1', '0'], ['x110x2', 'x010'], 'a1b0c') // 'ax110x2bx010c'

// edge case
str_replace([12, 23], [23, 45], '123') // '453'
StrUtil::replaceOnce([12, 23], [23, 45], '123') // false
str_replace([12, 23], [23, 45], '1223') // '4545'
StrUtil::replaceOnce([12, 23], [23, 45], '1223') // false

要求

需要 mbstring 扩展

安装

使用包管理器 composer 安装 phputils。

composer require talmp/phputils

测试

./vendor/bin/phpunit tests

贡献

欢迎提交拉取请求。对于重大变更,请先提出一个问题来讨论您想进行的更改。

请确保根据需要更新测试。

许可证

MIT