urmaul/formatter
Composer 安装命令:
composer require urmaul/formatter
包简介
Rule-based string format.
关键字:
README 文档
README
Rule-based string formatters. Made for polishing parsed data.
Installing
composer require urmaul/formatter dev-master
Using
$values = ['foo' => ' bar ', 'spam' => 'ham | foo | bar']; $formatter = new Formatter([ ['foo', 'trim'], ['spam', 'cut', ' | '], ]); $values = $formatter->format($values); // $values = ['foo' => 'bar', 'spam' => 'ham'];
Actions
- cut(delimiter) - returns string part between beginning and delimiter.
- rcut(delimiter) - returns string part between delimiter and ending.
- remove(substring) - removes substring. See str_replace.
- replace(substring, replacement) - replaces substring with replacement. See str_replace.
- removeMatch(pattern) - removes pattern. See preg_replace.
- replaceMatch(pattern, replacement) - replaces pattern with replacement. See preg_replace.
- map(array map) - replaces string with value from map.
- between(leftBorder, rightBorder) - returns string part between first occurence of leftBorder and rightBorder.
- trim([character_mask = " \t\n\r\0\x0B"]) - strips whitespace (or other characters) from the beginning and end of a string.
- callback(callable) - processes string with callback.
- grep(substring) - returns lines containing substring.
- stripTags([allowable_tags]) - strips HTML and PHP tags from a string. See strip_tags.
- iconv([encoding_from, encoding_to]) - converts character encoding. Defaults are "UTF-8" - "UTF-8//IGNORE" which remove invalid characters from utf-8 string.
- stripWhitespaces(string) - returns string without unprintable characters.
统计信息
- 总下载量: 151
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-06-06