PHPackages                             jonasrudolph/php-component-stringutility - 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. jonasrudolph/php-component-stringutility

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

jonasrudolph/php-component-stringutility
========================================

1.2.1(9y ago)313.4k1LGPLv3PHPPHP &gt;=5.5

Since May 5Pushed 8y ago1 watchersCompare

[ Source](https://github.com/JonasRudolph/php-component-stringutility)[ Packagist](https://packagist.org/packages/jonasrudolph/php-component-stringutility)[ RSS](/packages/jonasrudolph-php-component-stringutility/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (2)Dependencies (1)Versions (7)Used By (1)

[![Build Status](https://camo.githubusercontent.com/4427400e1cabc635d4dbaa86809fc9d98a271d8716670662b5b6093529cf11c0/68747470733a2f2f7472617669732d63692e6f72672f4a6f6e61735275646f6c70682f7068702d636f6d706f6e656e742d737472696e677574696c6974792e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/JonasRudolph/php-component-stringutility)[![Dependency Status](https://camo.githubusercontent.com/bb3795918f76f53d442d8253e0c294489d43597b09bb984bb775e7b5ca403da3/68747470733a2f2f67656d6e617369756d2e636f6d2f6261646765732f6769746875622e636f6d2f4a6f6e61735275646f6c70682f7068702d636f6d706f6e656e742d737472696e677574696c6974792e737667)](https://gemnasium.com/github.com/JonasRudolph/php-component-stringutility)
[![BCH compliance](https://camo.githubusercontent.com/64c0f9a73e0fcad52a8199638448a1ad764cb6200195bcfb9cab137034787e8b/68747470733a2f2f626574746572636f64656875622e636f6d2f656467652f62616467652f4a6f6e61735275646f6c70682f7068702d636f6d706f6e656e742d737472696e677574696c6974793f6272616e63683d6d6173746572)](https://bettercodehub.com/results/JonasRudolph/php-component-stringutility)[![Codacy Badge](https://camo.githubusercontent.com/e7d62a209f0927a124d3aae660395ef34cbc479e0cd60b9d095b09e89fb26d16/68747470733a2f2f6170692e636f646163792e636f6d2f70726f6a6563742f62616467652f47726164652f3830623336636633303534643430613139393130393836623235363630366332)](https://www.codacy.com/app/jonas.ru/php-component-stringutility)

php-component-stringutility
===========================

[](#php-component-stringutility)

- Well tested functions on strings:

```
use JonasRudolph\PHPComponents\StringUtility\Base\StringUtilityInterface;
use JonasRudolph\PHPComponents\StringUtility\Implementation\StringUtility;

/** @var StringUtilityInterface */
$stringUtility = new StringUtility();

$stringUtility->contains('mySecr3t', 'cr3') === true

$stringUtility->startsWith('https://my-domain.com', 'https') === true

$stringUtility->endsWith('www.my-domain.com/img/logo.svg', '.svg') === true;

$stringUtility->removePrefix('http://www.my-domain.com', 'http://') === 'www.my-domain.com'

$stringUtility->removeSuffix('my-domain.com', '.com') === 'my-domain'

$stringUtility->removeWhitespace("Any String\tWith\nWhitespace\r.\0") === 'AnyStringWithWitespace.'

$stringUtility->substringAfter('www.my-domain.com/index.php', '.com/') === 'index.php'

$stringUtility->substringBefore('www.my-domain.com/user?id=1&token=xyz', '?') === 'www.my-domain.com/user'

$stringUtility->substringBetween('there is no foo without a bar', 'no ', ' without') === 'foo'

$stringUtility->split('user@my-domain.com:secret', ':') === ['user@my-domain.com', 'secret']
```

Consistent rules used in all functions
--------------------------------------

[](#consistent-rules-used-in-all-functions)

- When a function searches for a needle anywhere in a string and the string contains the needle more than once - then, the function will use the first occurence of the needle in the string for further computations
    That means:

    ```
    $stringUtility->substringAfter('abefbg', 'b') === 'efbg'
    $stringUtility->substringBefore('abefbg', 'b') === 'a'
    $stringUtility->split('user@my-domain.com:secret', ':') === ['user@my-domain.com', 'secret']
    ```

    One exception is the substringBetween function which will search for the first $untilBefore-string *after* the occurence of the first $startAfter-string

    ```
    $stringUtility->substringBetween('abefbg', 'b', 'b') === 'ef'
    $stringUtility->substringBetween('abefbg', 'e', 'b') === 'f'
    $stringUtility->substringBetween('abcdefg', 'c', 'b') === 'defg'
    ```
- Every character of a a string is surrounded by the empty string ('') infinitly times
    That means:

    ```
    $stringUtility->contains($myString, '') === true
    $stringUtility->startsWith($myString, '') === true
    $stringUtility->endsWith($myString, '') === true;
    $stringUtility->substringAfter($myString, '') === $myString
    $stringUtility->substringBefore($myString, '') === ''
    $stringUtility->substringBetween('abcd', '', 'b') === 'a'
    $stringUtility->substringBetween($myString, $x, '') === ''
    $stringUtility->split($myString, '') === ['', $myString]
    ```

Contributors
------------

[](#contributors)

- [Jonas Rudolph](https://github.com/JonasRudolph)
- [Stev Leibelt](https://github.com/stevleibelt)

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 66.7% 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 ~68 days

Total

6

Last Release

3409d ago

### Community

Maintainers

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

---

Top Contributors

[![JonasTaulien](https://avatars.githubusercontent.com/u/8789042?v=4)](https://github.com/JonasTaulien "JonasTaulien (16 commits)")[![stevleibelt](https://avatars.githubusercontent.com/u/2287220?v=4)](https://github.com/stevleibelt "stevleibelt (8 commits)")

---

Tags

stringutilitysplitcontainsstartsWithendsWithremovePrefixremoveSuffixremoveWhitespacesubstringAftersubstringBeforesubstringBetween

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jonasrudolph-php-component-stringutility/health.svg)

```
[![Health](https://phpackages.com/badges/jonasrudolph-php-component-stringutility/health.svg)](https://phpackages.com/packages/jonasrudolph-php-component-stringutility)
```

###  Alternatives

[nette/utils

🛠 Nette Utils: lightweight utilities for string &amp; array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.

2.1k430.4M1.7k](/packages/nette-utils)[danielstjules/stringy

A string manipulation library with multibyte support

2.4k26.3M192](/packages/danielstjules-stringy)[voku/stringy

A string manipulation library with multibyte support

1863.9M25](/packages/voku-stringy)[statamic/stringy

A string manipulation library with multibyte support, forked from @statamic

245.0M18](/packages/statamic-stringy)[danielstjules/sliceable-stringy

Python string slices in PHP

4751.6k1](/packages/danielstjules-sliceable-stringy)[tcb13/substringy

A sub string manipulation library with multibyte support that extends Stringy

1761.0k1](/packages/tcb13-substringy)

PHPackages © 2026

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