![Stringy](http://danielstjules.com/github/stringy-logo.png)
A PHP string manipulation library with multibyte support. Offers both OO method
chaining and a procedural-style static wrapper. Tested and compatible with
PHP 5.3+ and HHVM. Inspired by underscore.string.js.
[![Build Status](https://api.travis-ci.org/danielstjules/Stringy.svg?branch=master)](https://travis-ci.org/danielstjules/Stringy)
* [Requiring/Loading](#requiringloading)
* [OO and Procedural](#oo-and-procedural)
* [Implemented Interfaces](#implemented-interfaces)
* [PHP 5.6 Creation](#php-56-creation)
* [Methods](#methods)
* [at](#at)
* [camelize](#camelize)
* [chars](#chars)
* [collapseWhitespace](#collapsewhitespace)
* [contains](#contains)
* [containsAll](#containsall)
* [containsAny](#containsany)
* [countSubstr](#countsubstr)
* [create](#create)
* [dasherize](#dasherize)
* [delimit](#delimit)
* [endsWith](#endswith)
* [ensureLeft](#ensureleft)
* [ensureRight](#ensureright)
* [first](#first)
* [getEncoding](#getencoding)
* [hasLowerCase](#haslowercase)
* [hasUpperCase](#hasuppercase)
* [htmlDecode](#htmldecode)
* [htmlEncode](#htmlencode)
* [humanize](#humanize)
* [indexOf](#indexof)
* [indexOfLast](#indexoflast)
* [insert](#insert)
* [isAlpha](#isalpha)
* [isAlphanumeric](#isalphanumeric)
* [isBlank](#isblank)
* [isHexadecimal](#ishexadecimal)
* [isJson](#isjson)
* [isLowerCase](#islowercase)
* [isSerialized](#isserialized)
* [isUpperCase](#isuppercase)
* [last](#last)
* [length](#length)
* [longestCommonPrefix](#longestcommonprefix)
* [longestCommonSuffix](#longestcommonsuffix)
* [longestCommonSubstring](#longestcommonsubstring)
* [lowerCaseFirst](#lowercasefirst)
* [pad](#pad)
* [padBoth](#padboth)
* [padLeft](#padleft)
* [padRight](#padright)
* [regexReplace](#regexreplace)
* [removeLeft](#removeleft)
* [removeRight](#removeright)
* [replace](#replace)
* [reverse](#reverse)
* [safeTruncate](#safetruncate)
* [shuffle](#shuffle)
* [slugify](#slugify)
* [startsWith](#startswith)
* [substr](#substr)
* [surround](#surround)
* [swapCase](#swapcase)
* [tidy](#tidy)
* [titleize](#titleize)
* [toAscii](#toascii)
* [toLowerCase](#tolowercase)
* [toSpaces](#tospaces)
* [toTabs](#totabs)
* [toTitleCase](#totitlecase)
* [toUpperCase](#touppercase)
* [trim](#trim)
* [trimLeft](#trimLeft)
* [trimRight](#trimRight)
* [truncate](#truncate)
* [underscored](#underscored)
* [upperCamelize](#uppercamelize)
* [upperCaseFirst](#uppercasefirst)
* [Links](#links)
* [Tests](#tests)
* [License](#license)
## Requiring/Loading
If you're using Composer to manage dependencies, you can include the following
in your composer.json file:
```json
{
"require": {
"danielstjules/stringy": "~1.10"
}
}
```
Then, after running `composer update` or `php composer.phar update`, you can
load the class using Composer's autoloading:
```php
require 'vendor/autoload.php';
```
Otherwise, you can simply require the file directly:
```php
require_once 'path/to/Stringy/src/Stringy.php';
// or
require_once 'path/to/Stringy/src/StaticStringy.php';
```
And in either case, I'd suggest using an alias.
```php
use Stringy\Stringy as S;
// or
use Stringy\StaticStringy as S;
```
## OO and Procedural
The library offers both OO method chaining with `Stringy\Stringy`, as well as
procedural-style static method calls with `Stringy\StaticStringy`. An example
of the former is the following:
```php
use Stringy\Stringy as S;
echo S::create('Fòô Bàř', 'UTF-8')->collapseWhitespace()->swapCase(); // 'fÒÔ bÀŘ'
```
`Stringy\Stringy` has a __toString() method, which returns the current string
when the object is used in a string context, ie:
`(string) S::create('foo') // 'foo'`
Using the static wrapper, an alternative is the following:
```php
use Stringy\StaticStringy as S;
$string = S::collapseWhitespace('Fòô Bàř', 'UTF-8');
echo S::swapCase($string, 'UTF-8'); // 'fÒÔ bÀŘ'
```
## Implemented Interfaces
`Stringy\Stringy` implements the `IteratorAggregate` interface, meaning that
`foreach` can be used with an instance of the class:
``` php
$stringy = S::create('Fòô Bàř', 'UTF-8');
foreach ($stringy as $char) {
echo $char;
}
// 'Fòô Bàř'
```
It implements the `Countable` interface, enabling the use of `count()` to
retrieve the number of characters in the string:
``` php
$stringy = S::create('Fòô', 'UTF-8');
count($stringy); // 3
```
Furthermore, the `ArrayAccess` interface has been implemented. As a result,
`isset()` can be used to check if a character at a specific index exists. And
since `Stringy\Stringy` is immutable, any call to `offsetSet` or `offsetUnset`
will throw an exception. `offsetGet` has been implemented, however, and accepts
both positive and negative indexes. Invalid indexes result in an
`OutOfBoundsException`.
``` php
$stringy = S::create('Bàř', 'UTF-8');
echo $stringy[2]; // 'ř'
echo $stringy[-2]; // 'à'
isset($stringy[-4]); // false
$stringy[3]; // OutOfBoundsException
$stringy[2] = 'a'; // Exception
```
## PHP 5.6 Creation
As of PHP 5.6, [`use function`](https://wiki.php.net/rfc/use_function) is
available for importing functions. Stringy exposes a namespaced function,
`Stringy\create`, which emits the same behaviour as `Stringy\Stringy::create()`.
If running PHP 5.6, or another runtime that supports the `use function` syntax,
you can take advantage of an even simpler API as seen below:
``` php
use function Stringy\create as s;
// Instead of: S::create('Fòô Bàř', 'UTF-8')
s('Fòô Bàř', 'UTF-8')->collapseWhitespace()->swapCase();
```
## Methods
In the list below, any static method other than S::create refers to a method in
`Stringy\StaticStringy`. For all others, they're found in `Stringy\Stringy`.
Furthermore, all methods that return a Stringy object or string do not modify
the original. Stringy objects are immutable.
*Note: If `$encoding` is not given, it defaults to `mb_internal_encoding()`.*
#### at
$stringy->at(int $index)
S::at(int $index [, string $encoding ])
Returns the character at $index, with indexes starting at 0.
```php
S::create('fòô bàř', 'UTF-8')->at(6);
S::at('fòô bàř', 6, 'UTF-8'); // 'ř'
```
#### camelize
$stringy->camelize();
S::camelize(string $str [, string $encoding ])
Returns a camelCase version of the string. Trims surrounding spaces,
capitalizes letters following digits, spaces, dashes and underscores,
and removes spaces, dashes, as well as underscores.
```php
S::create('Camel-Case')->camelize();
S::camelize('Camel-Case'); // 'camelCase'
```
#### chars
$stringy->chars();
S::chars(string $str [, string $encoding ])
Returns an array consisting of the characters in the string.
```php
S::create('Fòô Bàř', 'UTF-8')->chars();
S::chars('Fòô Bàř', 'UTF-8'); // array(F', 'ò', 'ô', ' ', 'B', 'à', 'ř')
```
#### collapseWhitespace
$stringy->collapseWhitespace()
S::collapseWhitespace(string $str [, string $encoding ])
Trims the string and replaces consecutive whitespace characters with a
single space. This includes tabs and newline characters, as well as
multibyte whitespace such as the thin space and ideographic space.
```php
S::create(' Ο συγγραφέας ')->collapseWhitespace();
S::collapseWhitespace(' Ο συγγραφέας '); // 'Ο συγγραφέας'
```
#### contains
$stringy->contains(string $needle [, boolean $caseSensitive = true ])
S::contains(string $haystack, string $needle [, boolean $caseSensitive = true [, string $encoding ]])
Returns true if the string contains $needle, false otherwise. By default,
the comparison is case-sensitive, but can be made insensitive
by setting $caseSensitive to false.
```php
S::create('Ο συγγραφέας �
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
flarum Flarum是使用php+MySQL进行开发的论坛类开源网站源码。 Flarum是新一代论坛软件,它使网上讨论变得乐趣。它简单,快速,而且免费。它使论坛变得简单。 环境要求: 需要PHP5.5+和MySQL5.5+ 特点: flarum是充满创新的,体现在这美丽简洁的设计。 她不只是一个漂亮的皮肤。 她是论坛软件的重启,的文艺复兴。 不臃肿、不复杂、不过度依赖。几分钟之内构建属于自己的社区。 Flarum 基于 PHP 构建,因此很容易安装部署。界面使用 Mithril 构建,Mithril 是一个高性能的 JavaScript 框架。更少的等待,更多的交流。 精美的响应式布局 如果 Flarum 的桌面版界面没有打动你的心,那么他的移动版一定会的。Flarum was born to be touched. Flarum 不仅仅为程序员开发,而是为所有人开发的。Flarum 在设计之初就考虑了跨平台,开箱即用。并且 Flarum 的界面风格使用了 LESS,这样很容易更换主题。 强大 简约,并不简陋。 定制性、可扩展性,都集成在了 Flarum 中。 构建可扩展的软件是很困难的。值得庆幸的是,我们有多年的开发 esoTalk 和 FluxBB 的经验。Flarum 的开源架构是非常灵活的,他拥有完善的 API 和文档。 原地址:http://www.sudujun.com/html/201702/313.html
资源推荐
资源详情
资源评论
收起资源包目录
Flarum中文优化版 Flarum汉化版 开源论坛网站源码 (2000个子文件)
a 0B
aliases 2KB
random_compat.phar.pubkey.asc 488B
symfony_debug.c 7KB
CHANGES 7KB
Less.php.combine 226B
abc.dat.copy 0B
ab.dat.copy 0B
a.dat.copy 0B
ca.crt 1KB
sign2.crt 1KB
encrypt2.crt 1KB
sign.crt 1KB
encrypt.crt 1KB
intermediate.crt 1KB
font-awesome.css 37KB
font-awesome.min.css 30KB
whoops.base.css 11KB
style.css 2KB
resources.csv 96B
valid.csv 36B
empty.csv 0B
resources.dat 352B
resources.dat 3B
bar.dat 0B
abc.dat 0B
ab.dat 0B
a.dat 0B
smoke.conf.php.default 2KB
acceptance.conf.php.default 1KB
phpunit.xml.dist 1KB
phpunit.xml.dist 1KB
phpunit.xml.dist 939B
phpunit.xml.dist 939B
phpunit.xml.dist 930B
phpunit.xml.dist 866B
phpunit.xml.dist 834B
phpunit.xml.dist 823B
phpunit.xml.dist 821B
phpunit.xml.dist 780B
phpunit.xml.dist 779B
phpunit.xml.dist 776B
phpunit.xml.dist 775B
phpunit.xml.dist 773B
phpunit.xml.dist 767B
phpunit.xml.dist 631B
phpunit.xml.dist 460B
phpunit.xml.dist 448B
phpunit.xml.dist 411B
phpunit.xml.dist 411B
phpunit.xml.dist 219B
phpunit.xml.dist 219B
doctrine-dbal 66B
doctrine-dbal 66B
docx.docx 20KB
.editorconfig 354B
.editorconfig 354B
.editorconfig 354B
.editorconfig 354B
.editorconfig 354B
.editorconfig 354B
.editorconfig 354B
.editorconfig 354B
.editorconfig 354B
.editorconfig 354B
.editorconfig 354B
.editorconfig 354B
.editorconfig 354B
.editorconfig 354B
.editorconfig 354B
.editorconfig 354B
.editorconfig 354B
.editorconfig 354B
.editorconfig 354B
.editorconfig 354B
.editorconfig 354B
.editorconfig 354B
.empty 0B
fontawesome-webfont.eot 162KB
fontawesome-webfont.eot 67KB
other-file.example 0B
hiddeninput.exe 9KB
flarum 381B
test.gif 35B
.gitattributes 378B
.gitattributes 157B
.gitattributes 72B
.gitignore 574B
.gitignore 134B
.gitignore 134B
.gitignore 123B
.gitignore 94B
.gitignore 71B
.gitignore 71B
.gitignore 67B
.gitignore 53B
.gitignore 50B
.gitignore 50B
.gitignore 50B
.gitignore 48B
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
一叶草
- 粉丝: 52
- 资源: 298
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于python开发的口红色号识别程序+源码+开发文档+源码解析(毕业设计&课程设计&项目开发)
- TP-LINK TL-WN725N V3 Linux 驱动
- 020ssm-jsp-mysql班级同学录网站.zip(可运行源码+数据库文件+文档)
- 什么是stm32f103rct6,有哪些优缺点?
- 李明哲尚能2.zip
- 019ssm-jsp-mysql奥迪维修保养服务管理系统.zip(可运行源码+数据库文件+)
- AB测试数据-增设中小店铺广告位
- YOLOv8红外场景的车辆-行人-斑马线-交通灯检测+数据集+pyqt界面
- 基于JSP毕业设计-OA办公自动化系统-毕业设计.zip
- 基于JSP毕业设计-MVC设计模式应用之游戏卡在线销售系统(论文).zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功