typedphp / string-functions
0.1.0
2014-12-15 18:35 UTC
Requires
- php: >=5.4.0
- typedphp/type-functions: *
Requires (Dev)
- phpunit/phpunit: 4.*
README
示例
use TypedPHP\Functions\StringFunctions; StringFunctions\endsWith("a long string", "string"); // true StringFunctions\replace("a long string", "long", "enormous"); // "a enormous string"
函数
startsWith(string $haystack, string $needle) → boolendsWith(string $haystack, string $needle) → boolindexOf(string $haystack, string $needle, int $offset = 0) → intlength(string $string) → intmatches(string $haystack, string $needle) → boolreplace(string $haystack, string|array $needle, string|array $replacement) → stringslice(string $string, int $offset = 0, int $limit = 0) → stringsplit(string $haystack, string|null $needle = null, int $limit = 0) → arraytrim(string $haystack, string $needle) → stringtrimLeft(string $haystack, string $needle) → stringtrimRight(string $haystack, string $needle) → string
注意事项
- 每个
$needle都可以是一个普通字符串或正则表达式字符串。
安装
❯ composer require "typedphp/string-functions:*"
测试
❯ composer create-project "typedphp/string-functions:*" . ❯ vendor/bin/phpunit