try / clear-string
清除特殊字符的字符串工具包
1.0.0
2017-10-20 20:15 UTC
This package is not auto-updated.
Last update: 2024-09-15 04:20:57 UTC
README
清除特殊字符的字符串工具包
安装
$ composer require try/clear-string
用法
<?php require_once '/path/to/autoload.php'; use TryPhp\stripControlCharacters; $clearedString = stripControlCharacters("Some Special\nMultiline String"); echo $clearedString; // will output "Some Special Multiline String";
API
函数
stripControlCharacters($contents)
用于从字符串中删除控制字符的函数。该函数将 \n
和 \t
替换为简单空格,并删除任何其他控制字符(\0
、\a
、\b
、\v
、\f
、\r
、\e
)。因此,它清理了输出,并允许更精确的文本比较。
参数
stripColorCharacters($contents)
用于从字符串中删除带有后续颜色代码(例如 \e[33m
)的转义字符(\e
)的函数。
参数
许可证
GPL-2.0 © Willi Eßer