webikevn/wstring

PHP 字符串工具

1.0.2 2020-08-21 06:04 UTC

This package is auto-updated.

Last update: 2024-09-21 15:22:34 UTC


README

这个库提供了简化字符串操作的实用函数

安装

使用composer安装包

composer require webikevn/wstring

在您的PHP代码中,加载库

require_once __DIR__ . '/../vendor/autoload.php';
use Webike\WString\WString as WString;

注意:由于String是PHP的保留词,所以我不能将其用作命名空间,因此命名空间是WString...

用法

替换字符串中最后一次出现的位置

$string = WString::strReplaceLast($search, $replace, $subject);

检查字符串是否以指定的字符开头

$bool = WString::startsWith($haystack, $needle);

检查字符串是否以指定的字符结尾

$bool = WString::endsWith($haystack, $needle);

单元测试

phpunit --bootstrap vendor/autoload.php tests

作者

Nguyen Giang 访问我的网站 ;)