![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('Ο συγγραφέας �
没有合适的资源?快使用搜索试试~ 我知道了~
魔众文档管理系统+支持Markdown图表脑图富文本等集合.zip
共2004个文件
js:719个
html:253个
txt:198个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 136 浏览量
2024-03-11
17:39:00
上传
评论
收藏 27.42MB ZIP 举报
温馨提示
魔众文档管理支持Markdown、图表、脑图、富文本,功能全面、安全稳定,支持标签、分类,可以更好的在线管理个人文档。 魔众文档管理系统,支持Markdown、图表、脑图、富文本的文档管理系统。 2022年10月19日魔众文档管理系统发布v5.3.0版本,增加了以下23个特性: ·[新功能] 文件上传表新增大类和分类索引 ·[新功能] 用户新增Meta信息,用于底层临时存储部分关联信息 ·[新功能] Request新增isGet方法用于判断GET请求方式 ·[新功能] 用户注册IP信息 ·[新功能] TextAjaxRequest组件部分属性重构和新增方法 ·[新功能] 后台登录背景优化 ·[新功能] 系统升级调用命令容错处理 ·[新功能] 数据库兼容MySQL8.0 ·[新功能] OpenApi和Api中间件新增AccessGate ·[新功能] 随机字符串新增大写和小写可读字符串 ·[新功能] 授权登录绑定手机和邮箱可配置 ·[新功能] 富文本过滤图片新增data-formula-image属性 ·[新功能] 手机快捷注册自动设置用户名和昵称
资源推荐
资源详情
资源评论
收起资源包目录
魔众文档管理系统+支持Markdown图表脑图富文本等集合.zip (2004个子文件)
symfony_debug.c 7KB
base.css 973KB
style.css 452KB
index.css 230KB
all.min.css 153KB
layui.css 78KB
editormd.css 61KB
editormd.css 61KB
editormd.min.css 60KB
editormd.min.css 60KB
skin.min.css 59KB
skin.min.css 59KB
video-js.css 48KB
editormd.preview.css 45KB
editormd.preview.css 45KB
editormd.preview.min.css 44KB
editormd.preview.min.css 44KB
ueditor.css 33KB
font-awesome.min.css 26KB
kityminder.editor.css 26KB
ambiance.css 25KB
ambiance.css 25KB
grapheditor.css 25KB
kityminder.editor.min.css 25KB
content.min.css 21KB
content.inline.min.css 21KB
content.inline.min.css 21KB
content.min.css 21KB
skin.mobile.min.css 20KB
skin.mobile.min.css 20KB
layer.css 13KB
swiper.css 13KB
vue.css 12KB
video.css 12KB
tagify.css 11KB
doc.css 11KB
doc.css 11KB
attachment.css 11KB
simplemde.css 11KB
image.css 10KB
layui.mobile.css 10KB
default-skin.css 8KB
laydate.css 7KB
shCoreDefault.css 7KB
iconfont.css 6KB
codemirror.css 5KB
codemirror.css 5KB
banner.css 5KB
banner.css 5KB
codemirror.min.css 5KB
codemirror.min.css 5KB
mdn-like.css 4KB
mdn-like.css 4KB
iframe.css 4KB
solarized.css 4KB
solarized.css 4KB
cropper.css 4KB
common.css 3KB
scrawl.css 3KB
merge.css 3KB
merge.css 3KB
lint.css 3KB
lint.css 3KB
style.css 2KB
photoswipe.css 2KB
codemirror.css 2KB
lesser-dark.css 2KB
lesser-dark.css 2KB
background.css 2KB
pastel-on-dark.css 2KB
pastel-on-dark.css 2KB
erlang-dark.css 2KB
erlang-dark.css 2KB
tomorrow-night-eighties.css 2KB
tomorrow-night-eighties.css 2KB
editormd.logo.min.css 2KB
editormd.logo.min.css 2KB
emotion.css 2KB
twilight.css 2KB
twilight.css 2KB
vibrant-ink.css 2KB
vibrant-ink.css 2KB
midnight.css 2KB
midnight.css 2KB
tern.css 2KB
tern.css 2KB
tomorrow-night-bright.css 1KB
tomorrow-night-bright.css 1KB
plain.css 1KB
admin.css 1KB
editormd.logo.css 1KB
editormd.logo.css 1KB
blackboard.css 1KB
blackboard.css 1KB
zenburn.css 1KB
zenburn.css 1KB
the-matrix.css 1KB
the-matrix.css 1KB
paraiso-light.css 1KB
paraiso-dark.css 1KB
共 2004 条
- 1
- 2
- 3
- 4
- 5
- 6
- 21
资源评论
智慧浩海
- 粉丝: 1w+
- 资源: 5450
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- jsp+sql毕业生招聘系统毕业设计(系统+论文+英文文献+综合材料)(2024qe).7z
- CNN卷积神经网络 训练集
- java项目之都市供求信息网源代码.zip
- jsp+sql智能交通道路管理系统(论文+任务书+外文翻译+开题报告+文献综述)(20246v).7z
- jsp+sql智能道路交通信息管理系统的设计与实现(论文+系统+开题报告+答辩PPT+外文翻译)(2024oq).7z
- JSP+SQL网上书店销售系统(论文+系统)(202431).7z
- jsp+基于JB的人事管理系统(源代码+论文)(2024me).7z
- jspOA办公自动化系统-毕业设计(2024u7).7z
- jsp个人理财系统(论文)(2024ol).7z
- jsp仓储管理系统设计(源代码+论文)(2024x4).7z
- JSP+sql实验教学管理系统(系统+论文+开题报告+封面+中期检查表+英文文献)(2024a7).7z
- JSP公司办公信息管理系统(源代码+论文)(2024f6).7z
- jsp+sql网络书店销售管理系统(论文+任务书+开题报告+中期检查表+摘要+英文文献)(202452).7z
- JSP+sql网络远程作业处理系统(系统+论文+开题报告+中英文摘要+封面+目录+资料)(2024ul).7z
- JSP+SQL网上书店设计(源代码+论文)(202422).7z
- JSP+SQL网上书店售书系统(源代码+论文+答辩PPT)(202494).7z
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功