ludovicm67 / strings
一些用于字符串处理的有用函数
v2.0.0
2021-01-17 13:58 UTC
Requires
- php: ^7.3|^8.0
Requires (Dev)
This package is auto-updated.
Last update: 2024-09-12 13:39:21 UTC
README
一些用于字符串处理的有用函数
安装
只需运行以下命令即可将其添加到您的PHP项目中:composer require ludovicm67/strings
入门
如果您使用composer安装,现在您可以创建一个包含以下代码的文件
<?php // import here the composer autoloader require('./vendor/autoload.php'); // use the namespace for this library use ludovicm67\Strings\Strings;
清理字符串
您可以使用静态方法:Strings::clean("我的字符串")来清理字符串。
示例
echo Strings::clean("test& ""~ "@éa/-âå€ÊÂøÊ±æ€ûýþ<b>bold</b>"); // will display: test& ""~ "@éa/-âå€ÊÂøÊ±æ€ûýþ<b>bold</b>
从驼峰式获取字符串
使用Strings::fromCamelCase("myString")(将返回:my-string)。
示例
echo Strings::fromCamelCase('testFromCamelCase'); // will display: test-from-camel-case
将字符串转换为驼峰式
使用Strings::toCamelCase("my-string")(将返回:myString)。
示例
echo Strings::toCamelCase('test-to-camel-case'); // will display: testToCamelCase
想要贡献?
只需分支、提交并打开一个pull请求。或者在这里打开一个issue:https://github.com/ludovicm67/php-strings/issues。