PHPackages                             eden/string - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. eden/string

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

eden/string
===========

Autoloading, error and exception handler

4.0.3(9y ago)2419.2k↑17.3%18MITPHPPHP &gt;=5.4.1

Since Oct 6Pushed 9y ago3 watchersCompare

[ Source](https://github.com/Eden-PHP/String)[ Packagist](https://packagist.org/packages/eden/string)[ Docs](http://eden-php.com)[ RSS](/packages/eden-string/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (1)Versions (7)Used By (18)

[![logo](https://camo.githubusercontent.com/683ba05b2b51f50045c674b19a4f0ceb30702a8ab495623be7c02e07ab226f08/687474703a2f2f6564656e2e6f70656e6f766174652e636f6d2f6173736574732f696d616765732f636c6f75642d736f6369616c2e706e67)](https://camo.githubusercontent.com/683ba05b2b51f50045c674b19a4f0ceb30702a8ab495623be7c02e07ab226f08/687474703a2f2f6564656e2e6f70656e6f766174652e636f6d2f6173736574732f696d616765732f636c6f75642d736f6369616c2e706e67) Eden String
=================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#-eden-string)

[![Build Status](https://camo.githubusercontent.com/bff31ef03f3359b82c07a1dfb8a359c563e1f960bca72c03e580df0419f27baa/68747470733a2f2f6170692e7472617669732d63692e6f72672f4564656e2d5048502f537472696e672e706e67)](https://travis-ci.org/Eden-PHP/String)
========================================================================================================================================================================================================================================================

[](#)

- [Install](#install)
- [Introduction](#intro)
- [API](#api)
    - [addslashes](#addslashes)
    - [bin2hex](#bin2hex)
    - [chunkSplit](#chunkSplit)
    - [convertUudecode](#convertUudecode)
    - [convertUuencode](#convertUuencode)
    - [countChars](#countChars)
    - [crypt](#crypt)
    - [explode](#explode)
    - [hex2bin](#hex2bin)
    - [htmlEntityDecode](#htmlEntityDecode)
    - [htmlentities](#htmlentities)
    - [htmlspecialchars](#htmlspecialchars)
    - [htmlspecialcharsDecode](#htmlspecialcharsDecode)
    - [ireplace](#ireplace)
    - [istr](#istr)
    - [lcfirst](#lcfirst)
    - [len](#len)
    - [ltrim](#ltrim)
    - [md5](#md5)
    - [nl2br](#nl2br)
    - [pad](#pad)
    - [pbrk](#pbrk)
    - [pos](#pos)
    - [pregReplace](#pregReplace)
    - [quotedPrintableDecode](#quotedPrintableDecode)
    - [quotedPrintableEncode](#quotedPrintableEncode)
    - [quotemeta](#quotemeta)
    - [repeat](#repeat)
    - [replace](#replace)
    - [rev](#rev)
    - [rot13](#rot13)
    - [rtrim](#rtrim)
    - [sha1](#sha1)
    - [shuffle](#shuffle)
    - [sprintf](#sprintf)
    - [str](#str)
    - [stripTags](#stripTags)
    - [stripcslashes](#stripcslashes)
    - [stripslashes](#stripslashes)
    - [substr](#substr)
    - [substrCompare](#substrCompare)
    - [substrCount](#substrCount)
    - [substrReplace](#substrReplace)
    - [tok](#tok)
    - [tolower](#tolower)
    - [toupper](#toupper)
    - [tr](#tr)
    - [trim](#trim)
    - [ucfirst](#ucfirst)
    - [ucwords](#ucwords)
    - [vsprintf](#vsprintf)
    - [wordwrap](#wordwrap)
- [Contributing](#contributing)

====

Install
-------

[](#install)

`composer install eden/string`

====

Enable Eden
-----------

[](#enable-eden)

The following documentation uses `eden()` in its example reference. Enabling this function requires an extra step as descirbed in this section which is not required if you access this package using the following.

```
Eden_String_Index::i();

```

When using composer, there is not an easy way to access functions from packages. As a workaround, adding this constant in your code will allow `eden()` to be available after.

```
Eden::DECORATOR;

```

For example:

```
Eden::DECORATOR;

eden()->inspect('Hello World');

```

====

Introduction
------------

[](#introduction)

Chainable string methods. When using multiple PHP string functions in one line, it makes code harder to read. This is because a programmer needs to be trained to read code from inner to outer, rather than traditionally left to right (unless you live in Japan). Eden's data typing are objects that correct this readability problem.

```
str_replace('L', 'y', strtoupper(substr('hello', 1, 3))); // Eyy

```

The above demonstrates that we must read this as `substr()`, then `strtoupper()`, followed by `str_replace()` which is inner function first going outwards. The example below shows how using types makes this line easier to read.

```
echo eden('string')->set('hello')->substr(1, 3)->toupper()->replace('L', 'y'); //--> Eyy

```

Expressed vertically as below shows something more pleasing to a developer.

```
echo eden('string')
	->set('hello')
	->substr(1, 3)
	->toupper()
	->replace('L', 'y'); //--> Eyy

```

When echoed the string object will automatically convert to a native string. Eden covers most of the string functions provided by PHP. Below is a list of string methods you can linearly perform.

====

API
---

[](#api)

====

### addslashes

[](#addslashes)

Same as PHP: addslashes

#### Usage

[](#usage)

```
eden('string')->addslashes();

```

#### Example

[](#example)

```
eden('string')->set('Hel"\'lo')->addslashes();

```

====

### bin2hex

[](#bin2hex)

Same as PHP: bin2hex

#### Usage

[](#usage-1)

```
eden('string')->bin2hex();

```

#### Example

[](#example-1)

```
eden('string')->set('01010100100')->bin2hex();

```

====

### chunkSplit

[](#chunksplit)

Same as PHP: chunk\_split

#### Usage

[](#usage-2)

```
eden('string')->chunkSplit(int $length, string $separator);

```

#### Example

[](#example-2)

```
eden('string')->set('Hello')->chunkSplit(2, ':');

```

====

### convertUudecode

[](#convertuudecode)

Same as PHP: convert\_uudecode

#### Usage

[](#usage-3)

```
eden('string')->convertUudecode();

```

#### Example

[](#example-3)

```
eden('string')->set('%2&5L;&\`\n`\n')->convertUudecode();

```

====

### convertUuencode

[](#convertuuencode)

Same as PHP: convert\_uuencode

#### Usage

[](#usage-4)

```
eden('string')->convertUuencode();

```

#### Example

[](#example-4)

```
eden('string')->set('Hello')->convertUuencode();

```

====

### countChars

[](#countchars)

Same as PHP: count\_chars

#### Usage

[](#usage-5)

```
eden('string')->countChars(int $min_length);

```

#### Example

[](#example-5)

```
eden('string')->set('Hello')->countChars(1);

```

====

### crypt

[](#crypt)

Same as PHP: crypt

#### Usage

[](#usage-6)

```
eden('string')->crypt(string $salt);

```

#### Example

[](#example-6)

```
eden('string')->set('Hello')->crypt('123');

```

====

### explode

[](#explode)

Same as PHP: explode

#### Usage

[](#usage-7)

```
eden('string')->explode(string $separator[,int $limit]);

```

#### Example

[](#example-7)

```
eden('string')->set('1-2-3-4')->explode('-');

```

====

### hex2bin

[](#hex2bin)

Same as PHP: hex2bin

#### Usage

[](#usage-8)

```
eden('string')->hex2bin();

```

#### Example

[](#example-8)

```
eden('string')->set('3031303130313030313030')->hex2bin();

```

====

### htmlEntityDecode

[](#htmlentitydecode)

Same as PHP: html\_entity\_decode

#### Usage

[](#usage-9)

```
eden('string')->htmlEntityDecode();

```

#### Example

[](#example-9)

```
eden('string')->set('&amp;')->htmlEntityDecode();

```

====

### htmlentities

[](#htmlentities)

Same as PHP: htmlentities

#### Usage

[](#usage-10)

```
eden('string')->htmlentities();

```

#### Example

[](#example-10)

```
eden('string')->set('&')->htmlentities();

```

====

### htmlspecialchars

[](#htmlspecialchars)

Same as PHP: htmlspecialchars

#### Usage

[](#usage-11)

```
eden('string')->htmlspecialchars();

```

#### Example

[](#example-11)

```
eden('string')->set('&')->htmlspecialchars();

```

====

### htmlspecialcharsDecode

[](#htmlspecialcharsdecode)

Same as PHP: htmlspecialchars\_decode

#### Usage

[](#usage-12)

```
eden('string')->htmlspecialcharsDecode();

```

#### Example

[](#example-12)

```
eden('string')->set('&amp;')->htmlspecialcharsDecode();

```

====

### lcfirst

[](#lcfirst)

Same as PHP: lcfirst

#### Usage

[](#usage-13)

```
eden('string')->lcfirst();

```

#### Example

[](#example-13)

```
eden('string')->set('Hello')->lcfirst();

```

====

### ltrim

[](#ltrim)

Same as PHP: ltrim

#### Usage

[](#usage-14)

```
eden('string')->ltrim();

```

#### Example

[](#example-14)

```
eden('string')->set('   Hello')->ltrim();

```

====

### md5

[](#md5)

Same as PHP: md5

#### Usage

[](#usage-15)

```
eden('string')->md5();

```

#### Example

[](#example-15)

```
eden('string')->set('Hello')->md5();

```

====

### nl2br

[](#nl2br)

Same as PHP: nl2br

#### Usage

[](#usage-16)

```
eden('string')->nl2br();

```

#### Example

[](#example-16)

```
eden('string')->set("Hel\nlo")->nl2br();

```

====

### pregReplace

[](#pregreplace)

Same as PHP: preg\_replace

#### Usage

[](#usage-17)

```
eden('string')->pregReplace(string $regex, string $replacement);

```

#### Example

[](#example-17)

```
eden('string')->set('Hello')->pregReplace('/e/', 'i');

```

====

### quotedPrintableDecode

[](#quotedprintabledecode)

Same as PHP: quoted\_printable\_decode

#### Usage

[](#usage-18)

```
eden('string')->quotedPrintableDecode();

```

#### Example

[](#example-18)

```
eden('string')->set('Hello')->quotedPrintableDecode();

```

====

### quotedPrintableEncode

[](#quotedprintableencode)

Same as PHP: quoted\_printable\_encode

#### Usage

[](#usage-19)

```
eden('string')->quotedPrintableEncode();

```

#### Example

[](#example-19)

```
eden('string')->set('Hello')->quotedPrintableEncode();

```

====

### quotemeta

[](#quotemeta)

Same as PHP: quotemeta

#### Usage

[](#usage-20)

```
eden('string')->quotemeta();

```

#### Example

[](#example-20)

```
eden('string')->set('Hello')->quotemeta();

```

====

### rtrim

[](#rtrim)

Same as PHP: rtrim

#### Usage

[](#usage-21)

```
eden('string')->rtrim();

```

#### Example

[](#example-21)

```
eden('string')->set('Hello   ')->rtrim();

```

====

### sha1

[](#sha1)

Same as PHP: sha1

#### Usage

[](#usage-22)

```
eden('string')->sha1();

```

#### Example

[](#example-22)

```
eden('string')->set('Hello')->sha1();

```

====

### sprintf

[](#sprintf)

Same as PHP: sprintf

#### Usage

[](#usage-23)

```
eden('string')->sprintf([mixed $variable[, mixed $variable2 ..]]);

```

#### Example

[](#example-23)

```
eden('string')->set('Hello %s')->sprintf('You');

```

====

### ireplace

[](#ireplace)

Same as PHP: str\_ireplace

#### Usage

[](#usage-24)

```
eden('string')->ireplace(string $needle, string $replacement);

```

#### Example

[](#example-24)

```
eden('string')->set('Hello')->ireplace('l', 'y');

```

====

### pad

[](#pad)

Same as PHP: str\_pad

#### Usage

[](#usage-25)

```
eden('string')->pad(int $length, string $replacement);

```

#### Example

[](#example-25)

```
eden('string')->set('Hello')->pad(7, 'o');

```

====

### repeat

[](#repeat)

Same as PHP: str\_repeat

#### Usage

[](#usage-26)

```
eden('string')->repeat(int $multiplier);

```

#### Example

[](#example-26)

```
eden('string')->set('Hello')->repeat(3);

```

====

### replace

[](#replace)

Same as PHP: str\_replace

#### Usage

[](#usage-27)

```
eden('string')->replace(string $needle, string $replacement);

```

#### Example

[](#example-27)

```
eden('string')->set('Hello')->replace('l', 'y');

```

====

### rot13

[](#rot13)

Same as PHP: str\_rot13

#### Usage

[](#usage-28)

```
eden('string')->rot13();

```

#### Example

[](#example-28)

```
eden('string')->set('Hello')->rot13();

```

====

### shuffle

[](#shuffle)

Same as PHP: str\_shuffle

#### Usage

[](#usage-29)

```
eden('string')->shuffle();

```

#### Example

[](#example-29)

```
eden('string')->set('Hello')->shuffle();

```

====

### stripTags

[](#striptags)

Same as PHP: strip\_tags

#### Usage

[](#usage-30)

```
eden('string')->stripTags([string $allowableTags]);

```

#### Example

[](#example-30)

```
eden('string')->set('Hello')->stripTags();

```

====

### stripcslashes

[](#stripcslashes)

Same as PHP: stripcslashes

#### Usage

[](#usage-31)

```
eden('string')->stripcslashes();

```

#### Example

[](#example-31)

```
eden('string')->set('Hello')->stripcslashes();

```

====

### stripslashes

[](#stripslashes)

Same as PHP: stripslashes

#### Usage

[](#usage-32)

```
eden('string')->stripslashes();

```

#### Example

[](#example-32)

```
eden('string')->set('He\\llo')->stripslashes();

```

====

### istr

[](#istr)

Same as PHP: stristr

#### Usage

[](#usage-33)

```
eden('string')->istr(string $needle);

```

#### Example

[](#example-33)

```
eden('string')->set('Hello')->istr('e');

```

====

### len

[](#len)

Same as PHP: strlen

#### Usage

[](#usage-34)

```
eden('string')->len();

```

#### Example

[](#example-34)

```
eden('string')->set('Hello')->len();

```

====

### pbrk

[](#pbrk)

Same as PHP: strpbrk

#### Usage

[](#usage-35)

```
eden('string')->pbrk(string $needle);

```

#### Example

[](#example-35)

```
eden('string')->set('Hello')->pbrk('abcdefgh');

```

====

### pos

[](#pos)

Same as PHP: strpos

#### Usage

[](#usage-36)

```
eden('string')->pos(string $needle);

```

#### Example

[](#example-36)

```
eden('string')->set('Hello')->pos('e');

```

====

### rev

[](#rev)

Same as PHP: strrev

#### Usage

[](#usage-37)

```
eden('string')->rev();

```

#### Example

[](#example-37)

```
eden('string')->set('Hello')->rev();

```

====

### str

[](#str)

Same as PHP: strstr

#### Usage

[](#usage-38)

```
eden('string')->str(string $needle);

```

#### Example

[](#example-38)

```
eden('string')->set('Hello')->str('e');

```

====

### tok

[](#tok)

Same as PHP: strtok

#### Usage

[](#usage-39)

```
eden('string')->tok(string $needle);

```

#### Example

[](#example-39)

```
eden('string')->set('Hello')->tok('e');

```

====

### tolower

[](#tolower)

Same as PHP: strtolower

#### Usage

[](#usage-40)

```
eden('string')->tolower();

```

#### Example

[](#example-40)

```
eden('string')->set('Hello')->tolower();

```

====

### toupper

[](#toupper)

Same as PHP: strtoupper

#### Usage

[](#usage-41)

```
eden('string')->toupper();

```

#### Example

[](#example-41)

```
eden('string')->set('Hello')->toupper();

```

====

### tr

[](#tr)

Same as PHP: strtr

#### Usage

[](#usage-42)

```
eden('string')->tr(string $needle, string $replacement);

```

#### Example

[](#example-42)

```
eden('string')->set('Hello')->tr('e', 'y');

```

====

### substr

[](#substr)

Same as PHP: substr

#### Usage

[](#usage-43)

```
eden('string')->substr(int $start[, int $length]);

```

#### Example

[](#example-43)

```
eden('string')->set('Hello')->substr(2, 2);

```

====

### substrCompare

[](#substrcompare)

Same as PHP: substr\_compare

#### Usage

[](#usage-44)

```
eden('string')->substrCompare(string $needle, int $index);

```

#### Example

[](#example-44)

```
eden('string')->set('Hello')->substrCompare('el', 3);

```

====

### substrCount

[](#substrcount)

Same as PHP: substr\_count

#### Usage

[](#usage-45)

```
eden('string')->substrCount(string $needle);

```

#### Example

[](#example-45)

```
eden('string')->set('Hello')->substrCount('l');

```

====

### substrReplace

[](#substrreplace)

Same as PHP: substr\_replace

#### Usage

[](#usage-46)

```
eden('string')->substrReplace(string $replacement, int $start, int $length);

```

#### Example

[](#example-46)

```
eden('string')->set('Hello')->substrReplace('yy', 2, 2);

```

====

### trim

[](#trim)

Same as PHP: trim

#### Usage

[](#usage-47)

```
eden('string')->trim();

```

#### Example

[](#example-47)

```
eden('string')->set('Hello')->trim();

```

====

### ucfirst

[](#ucfirst)

Same as PHP: ucfirst

#### Usage

[](#usage-48)

```
eden('string')->ucfirst();

```

#### Example

[](#example-48)

```
eden('string')->set('Hello')->ucfirst();

```

====

### ucwords

[](#ucwords)

Same as PHP: ucwords

#### Usage

[](#usage-49)

```
eden('string')->ucwords();

```

#### Example

[](#example-49)

```
eden('string')->set('Hello')->ucwords();

```

====

### vsprintf

[](#vsprintf)

Same as PHP: vsprintf

#### Usage

[](#usage-50)

```
eden('string')->vsprintf(array $replacements);

```

#### Example

[](#example-50)

```
eden('string')->set('Hello %s')->vsprintf(array('You'));

```

====

### wordwrap

[](#wordwrap)

Same as PHP: wordwrap

#### Usage

[](#usage-51)

```
eden('string')->wordwrap(int $length[, string $replacement]);

```

#### Example

[](#example-51)

```
eden('string')->set('Hello You')->wordwrap(3, '');

```

====

\#Contributing to Eden

Contributions to *Eden* are following the Github work flow. Please read up before contributing.

\##Setting up your machine with the Eden repository and your fork

1. Fork the repository
2. Fire up your local terminal create a new branch from the `v4` branch of your fork with a branch name describing what your changes are. Possible branch name types:
    - bugfix
    - feature
    - improvement
3. Make your changes. Always make sure to sign-off (-s) on all commits made (git commit -s -m "Commit message")

\##Making pull requests

1. Please ensure to run `phpunit` before making a pull request.
2. Push your code to your remote forked version.
3. Go back to your forked version on GitHub and submit a pull request.
4. An Eden developer will review your code and merge it in when it has been classified as suitable.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity36

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~58 days

Recently: every ~72 days

Total

6

Last Release

3586d ago

PHP version history (2 changes)v3PHP &gt;=5.3.1

4.0.1PHP &gt;=5.4.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/120378?v=4)[Christian Blanquera](/maintainers/cblanquera)[@cblanquera](https://github.com/cblanquera)

---

Top Contributors

[![clark21](https://avatars.githubusercontent.com/u/5639521?v=4)](https://github.com/clark21 "clark21 (9 commits)")

---

Tags

libraryeden

### Embed Badge

![Health badge](/badges/eden-string/health.svg)

```
[![Health](https://phpackages.com/badges/eden-string/health.svg)](https://phpackages.com/packages/eden-string)
```

###  Alternatives

[league/iso3166

ISO 3166-1 PHP Library

69536.3M116](/packages/league-iso3166)[dekor/php-array-table

PHP Library for printing associative arrays as text table (similar to mysql terminal console)

296.6M2](/packages/dekor-php-array-table)[eden/core

Eden Core component full of secret sauce

14415.0k34](/packages/eden-core)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
