PHPackages                             fyre/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. fyre/string

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

fyre/string
===========

A string utility library.

v3.0.2(6mo ago)0261MITPHP

Since Oct 26Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/elusivecodes/FyreString)[ Packagist](https://packagist.org/packages/fyre/string)[ RSS](/packages/fyre-string/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (10)Dependencies (4)Versions (26)Used By (1)

FyreString
==========

[](#fyrestring)

**FyreString** is a free, open-source string manipulation library for *PHP*.

Table Of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Methods](#methods)

Installation
------------

[](#installation)

**Using Composer**

```
composer require fyre/string

```

In PHP:

```
use Fyre\Utility\Str;
```

Methods
-------

[](#methods)

**After**

Get the contents of a string after the first occurrence of a substring.

- `$string` is the input string.
- `$search` is a string representing the value to search for.

```
$after = Str::after($string, $search);
```

If the `search` string is not found, this method will return the original string.

**After Last**

Get the contents of a string after the last occurrence of a substring.

- `$string` is the input string.
- `$search` is a string representing the value to search for.

```
$afterLast = Str::afterLast($string, $search);
```

If the `search` string is not found, this method will return the original string.

**Before**

Get the contents of a string before the first occurrence of a substring.

- `$string` is the input string.
- `$search` is a string representing the value to search for.

```
$before = Str::before($string, $search);
```

If the `search` string is not found, this method will return an empty string.

**Before Last**

Get the contents of a string before the last occurrence of a substring.

- `$string` is the input string.
- `$search` is a string representing the value to search for.

```
$beforeLast = Str::beforeLast($string, $search);
```

If the `search` string is not found, this method will return an empty string.

**Camel**

Convert a string into camelCase.

- `$string` is the input string.

```
$camel = Str::camel($string);
```

**Capitalize**

Capitalize the first character of a string.

- `$string` is the input string.

```
$capitalized = Str::capitalize($string);
```

**Chunk**

Split a string into smaller chunks.

- `$string` is the input string.
- `$size` is a number representing the maximum length of a chunk, and will default to *1*.

```
$chunks = Str::chunks($string, $size);
```

**Contains**

Determine whether a string contains a substring.

- `$string` is the input string.
- `$search` is a string representing the value to search for.

```
$contains = Str::contains($string, $search);
```

**Contains All**

Determine whether a string contains all substrings.

- `$string` is the input string.
- `$searches` is an array containing search strings.

```
$containsAll = Str::containsAll($string, $searches);
```

**Contains Any**

Determine whether a string contains any substring.

- `$string` is the input string.
- `$searches` is an array containing search strings.

```
$containsAny = Str::containsAny($string, $searches);
```

**End**

Append a substring to a string (if it does not already end with the substring).

- `$string` is the input string.
- `$search` is a string representing the value to append.

```
$end = Str::end($string, $search);
```

**Ends With**

Determine whether a string ends with a substring.

- `$string` is the input string.
- `$search` is a string representing the value to search for.

```
$endsWith = Str::endsWith($string, $search);
```

**Escape**

Escape characters in a string for use in HTML.

- `$string` is the input string.
- `$flags` is a number representing the flags to use when escaping, and will default to *Str::ENT\_QUOTES | Str::ENT\_HTML5*.

```
$escaped = Str::escape($string, $flags);
```

**Index Of**

Get the position of the first occurrence of a substring within a string.

- `$string` is the input string.
- `$search` is a string representing the value to search for.
- `$start` is a number representing the starting offset, and will default to 0.

```
$indexOf = Str::indexOf($string, $search);
```

If the `search` string is not found, this method will return *-1*.

**Is String**

Determine whether the value is a string.

- `$value` is the value to test.

```
$isString = Str::isString($value);
```

**Kebab**

Convert a string into kebab-case.

- `$string` is the input string.

```
$kebab = Str::kebab($string);
```

**Last Index Of**

Get the position of the last occurrence of a substring within a string.

- `$string` is the input string.
- `$search` is a string representing the value to search for.
- `$start` is a number representing the starting offset, and will default to 0.

```
$lastIndexOf = Str::lastIndexOf($string, $search);
```

If the `search` string is not found, this method will return *-1*.

**Length**

Get the length of a string (in bytes).

- `$string` is the input string.

```
$length = Str::length($string);
```

**Limit**

Limit a string to a specified number of bytes.

- `$string` is the input string.
- `$limit` is a number representing the number of bytes to split the string after.
- `$append` is a string representing the value to append if the string is split, and will default to "*…*".

```
$limited = Str::limit($string, $limit, $append);
```

**Lower**

Convert a string into lowercase.

- `$string` is the input string.

```
$lower = Str::lower($string);
```

**Pad**

Pad a string to a specified length.

- `$string` is the input string.
- `$length` is a number representing the desired length.
- `$padding` is a string representing the padding to use, and will default to *" "*.

```
$padded = Str::pad($string, $length, $padding);
```

**Pad End**

Pad the end of a string to a specified length.

- `$string` is the input string.
- `$length` is a number representing the desired length.
- `$padding` is a string representing the padding to use, and will default to *" "*.

```
$padded = Str::padEnd($string, $length, $padding);
```

**Pad Start**

Pad the start of a string to a specified length.

- `$string` is the input string.
- `$length` is a number representing the desired length.
- `$padding` is a string representing the padding to use, and will default to *" "*.

```
$padded = Str::padStart($string, $length, $padding);
```

**Pascal**

Convert a string into PascalCase.

- `$string` is the input string.

```
$pascal = Str::pascal($string);
```

**Random**

Generate a random string.

- `$length` is the length of the string to generate, and will default to *16*.
- `$chars` is a string representing the characters to use, and will default to "*abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWYXZ0123456789*".

```
$random = Str::random($length, $chars);
```

**Repeat**

Repeat a string a specified number of times.

- `$string` is the input string.
- `$count` is a number representing the number of times to repeat the string.

```
$repeated = Str::repeat($string, $count);
```

**Replace**

Search and replace a value within a string.

- `$string` is the input string.
- `$search` is a string representing the value to replace.
- `$replace` is a string representing the replacement value.

```
$replaced = Str::replace($string, $search, $replace);
```

**Replace Array**

Search and replace a value within a string.

- `$string` is the input string.
- `$search` is a string representing the value to replace.
- `$replacements` is an array containing replacement strings.

```
$replaced = Str::replaceArray($string, $search, $replacements);
```

**Replace At**

Replace text within a portion of a string.

- `$string` is the input string.
- `$replace` is a string representing the replacement value.
- `$position` is a number representing the position to replace from.
- `$length` is a number representing the length to replace.

```
$replaced = Str::replaceAt($string, $replace, $position, $length);
```

**Replace Each**

Search and replace key/value pairs within a string.

- `$string` is the input string.
- `$replacements` is an array containing replacements.

```
$replaced = Str::replaceEach($string, $replacements);
```

**Replace First**

Search and replace the first occurrence of a value within a string.

- `$string` is the input string.
- `$search` is a string representing the value to replace.
- `$replace` is a string representing the replacement value.

```
$replaced = Str::replaceFirst($string, $search, $replace);
```

**Replace Last**

Search and replace the last occurrence of a value within a string.

- `$string` is the input string.
- `$search` is a string representing the value to replace.
- `$replace` is a string representing the replacement value.

```
$replaced = Str::replaceLast($string, $search, $replace);
```

**Reverse**

Reverse the contents of a string.

- `$string` is the input string.

```
$reversed = Str::reverse($string);
```

**Shuffle**

Shuffle the contents of a string.

- `$string` is the input string.

```
$shuffled = Str::shuffle($string);
```

**Slice**

Return a specified portion of a string.

- `$string` is the input string.
- `$start` is a number representing the starting offset.
- `$length` is a number representing the maximum length to return, and will default to *PHP\_INT\_MAX*.

```
$sliced = Str::slice($string, $start, $length);
```

**Slug**

Format a string for use in a URL.

- `$string` is the input string.
- `$delimiter` is a string representing the delimiter to use, and will default to *"\_"*.

```
$slug = Str::slug($string, $delimiter);
```

**Snake**

Convert a string into snake\_case.

- `$string` is the input string.

```
$snake = Str::snake($string);
```

**Split**

Split a string by a specified delimiter.

- `$string` is the input string.
- `$delimiter` is a string representing the delimiter to split by.
- `$limit` is a number representing the maximum number of substrings to return, and will default to *PHP\_INT\_MAX*.

```
$split = Str::split($string, $delimiter, $limit);
```

**Start**

Prepend a substring to a string (if it does not already begin with the substring).

- `$string` is the input string.
- `$search` is a string representing the value to prepend.

```
$start = Str::start($string, $search);
```

**Starts With**

Determine whether a string begins with a substring.

- `$string` is the input string.
- `$search` is a string representing the value to search for.

```
$startsWith = Str::startsWith($string, $search);
```

**Title**

Capitalize the first character of each word in a string.

- `$string` is the input string.

```
$title = Str::title($string);
```

**Transliterate**

Transliterate the characters of a string into ASCII.

- `$string` is the input string.

```
$transliterated = Str::transliterate($string);
```

**Trim**

Trim whitespace (or other characters) from the start and end of a string.

- `$string` is the input string.
- `$mask` is a string representing the characters to trim, and will default to *" \\t\\n\\r\\0\\x0B"*.

```
$trimmed = Str::trim($string, $mask);
```

**Trim End**

Trim whitespace (or other characters) from the end of a string.

- `$string` is the input string.
- `$mask` is a string representing the characters to trim, and will default to *" t\\n\\r\\0\\x0B"*.

```
$trimmed = Str::trimEnd($string, $mask);
```

**Trim Start**

Trim whitespace (or other characters) from the start of a string.

- `$string` is the input string.
- `$mask` is a string representing the characters to trim, and will default to " *\\t\\n\\r\\0\\x0B*".

```
$trimmed = Str::trimStart($string, $mask);
```

**Upper**

Convert a string into uppercase.

- `$string` is the input string.

```
$upper = Str::upper($string);
```

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance66

Regular maintenance activity

Popularity6

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity60

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 ~60 days

Recently: every ~21 days

Total

25

Last Release

208d ago

Major Versions

v1.0.5 → v2.02023-07-08

v2.0.15 → v3.02025-09-24

### Community

Maintainers

![](https://www.gravatar.com/avatar/fad81fd5941e3a637c8a5749d05ae3ed9314d5e2fee57f59c3d9ec3b41259c6b?d=identicon)[elusivecodes](/maintainers/elusivecodes)

---

Top Contributors

[![elusivecodes](https://avatars.githubusercontent.com/u/18050480?v=4)](https://github.com/elusivecodes "elusivecodes (27 commits)")

---

Tags

phpstringtextutility

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

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

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

###  Alternatives

[droptica/droopler

Droopler - SEO Friendly CMS &amp; Site Builder - is a Drupal-based website builder that helps you create beautiful, fast, and easy-to-manage websites

6543.1k1](/packages/droptica-droopler)[facebook/facebook-for-magento

Facebook For Magento

852.0k](/packages/facebook-facebook-for-magento)[sinergi/token

PHP library to generate random strings

188.7k9](/packages/sinergi-token)

PHPackages © 2026

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