1
0
mirror of https://github.com/danielstjules/Stringy.git synced 2025-09-02 01:22:37 +02:00

Added slice

This commit is contained in:
Daniel St. Jules
2015-07-25 12:59:23 -07:00
parent 342ef7c3dd
commit 5e3ac6231c
3 changed files with 74 additions and 0 deletions

View File

@@ -70,6 +70,7 @@ s('string')->toTitleCase()->ensureRight('y') == 'Stringy'
* [shuffle](#shuffle)
* [slugify](#slugify-string-replacement----)
* [startsWith](#startswithstring-substring--boolean-casesensitive--true-)
* [slice](#sliceint-start--int-end-)
* [substr](#substrint-start--int-length-)
* [surround](#surroundstring-substring)
* [swapCase](#swapcase)
@@ -697,6 +698,17 @@ by setting $caseSensitive to false.
S::create('FÒÔ bàřs')->startsWith('fòô bàř', false); // true
```
##### slice(int $start [, int $end ])
Returns the substring beginning at $start, and up to, but not including
the index specified by $end. If $end is omitted, the function extracts
the remaining string. If $end is negative, it is computed from the end
of the string.
```php
S::create('fòôbàř')->slice(3, -1); // 'bà'
```
##### substr(int $start [, int $length ])
Returns the substring beginning at $start with the specified $length.