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

Add first() and last()

This commit is contained in:
Daniel St. Jules
2013-07-27 14:41:29 -04:00
parent f3ac2bf1f3
commit 77ae682de1
6 changed files with 162 additions and 8 deletions

View File

@@ -41,6 +41,8 @@ Note: The methods listed below are subject to change until we reach a 1.0.0 rele
* [length](#length)
* [substr](#substr)
* [at](#at)
* [first](#first)
* [last](#last)
* [Tests](#tests)
* [License](#license)
@@ -602,6 +604,32 @@ S::create('fòô bàř', 'UTF-8')->at(6);
S::at('fòô bàř', 6, 'UTF-8'); // 'ř'
```
##### first
$stringy->first(int $n)
S::first(int $n [, string $encoding ])
Gets the first $n characters of $str.
```php
S::create('fòô bàř', 'UTF-8')->first(3);
S::first('fòô bàř', 3, 'UTF-8'); // 'fòô'
```
##### last
$stringy->last(int $n)
S::last(int $n [, string $encoding ])
Gets the last $n characters of $str.
```php
S::create('fòô bàř', 'UTF-8')->last(3);
S::last('fòô bàř', 3, 'UTF-8'); // 'bàř'
```
## TODO
**count** => substr_count
@@ -626,14 +654,6 @@ S::at('fòô bàř', 6, 'UTF-8'); // 'ř'
**pluralize** ($count, $singular, $plural = null)
**first**
**last**
**from**
**to**
**toBoolean**
**ensureLeft**