PHPackages                             10quality/php-string-juggler - 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. 10quality/php-string-juggler

ActiveLibrary

10quality/php-string-juggler
============================

Juggling with strings in PHP.

v1.0.1(8y ago)127MITPHPPHP &gt;=5.4

Since Mar 21Pushed 8y ago2 watchersCompare

[ Source](https://github.com/10quality/php-string-juggler)[ Packagist](https://packagist.org/packages/10quality/php-string-juggler)[ Docs](https://github.com/10quality/php-string-juggler)[ RSS](/packages/10quality-php-string-juggler/feed)WikiDiscussions v1.0 Synced today

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

PHP String Juggler
==================

[](#php-string-juggler)

[![Latest Stable Version](https://camo.githubusercontent.com/b80e00669a3ce6d0fca9c0af61fa32dad2ea57c16923508d3a3d668ee2058d98/68747470733a2f2f706f7365722e707567782e6f72672f31307175616c6974792f7068702d737472696e672d6a7567676c65722f762f737461626c65)](https://packagist.org/packages/10quality/php-string-juggler)[![Total Downloads](https://camo.githubusercontent.com/64dd5ca33b000caf114ff5dd0444ead32bae5fd4130246f8c416708211f84c26/68747470733a2f2f706f7365722e707567782e6f72672f31307175616c6974792f7068702d737472696e672d6a7567676c65722f646f776e6c6f616473)](https://packagist.org/packages/10quality/php-string-juggler)[![License](https://camo.githubusercontent.com/f4867267d346f6e3cb850366e7e5fa457887a6f8eaeb273e54e6980cc2b5576f/68747470733a2f2f706f7365722e707567782e6f72672f31307175616c6974792f7068702d737472696e672d6a7567676c65722f6c6963656e7365)](https://packagist.org/packages/10quality/php-string-juggler)

Juggling with strings in PHP.

This is a forked version of [Christian Johansson](https://github.com/cjohansson)'s phpStringJuggler library.

**Major changes:**

- PHP 7 support.
- Composer support.
- PHPunit.

Install
-------

[](#install)

```
composer require 10quality/php-string-juggler
```

Purpose
-------

[](#purpose)

The idea is the make it easier to process strings in a object-oriented way.

An instantiated class is compatible with a string so you can use all functions for strings on a instantiated class.

Like this:

```
$string = new StringJuggler\Juggler('DONEC');`
echo strtolower($string);
// Echoes 'donec'
```

Examples
--------

[](#examples)

Sometimes examples is the best way to learn.

### 1. Create a StringJuggler

[](#1-create-a-stringjuggler)

```
// Use statement
use StringJuggler\Juggler;

$string = new Juggler('Donec id elit non mi porta gravida at eget metus.');
```

### 2. Juggle before

[](#2-juggle-before)

```
$before = $string->getBefore(' id');
// $before now equals 'Donec'
```

### 3. Juggle after

[](#3-juggle-after)

```
$after = $string->getAfter('porta ');
// $after now equals 'gravida at eget metus.'
```

### 4. Juggle in a conditional statement

[](#4-juggle-in-a-conditional-statement)

```
if (($after = $string->getAfter('porta ')) == 'gravida at eget metus.') {
	.. do something
} else {
	.. do something else
}
```

If you need to verify if something was found compare with '' rather than boolean false, like this, or use the `isEmpty()` and `isNotEmpty()` methods.

```
if (($after = $string->getAfter('porta ')) != '') {
	.. do something
} else {
	.. do something else
}
```

```
if ($string->getAfter('porta ')->isNotEmpty()) {
	.. do something
} else {
	.. do something else
}
```

Because the StringJuggler class will **always equal true but not always equal an empty string**. That behavior is caused by PHP.

### 5. Juggle a lot

[](#5-juggle-a-lot)

```
$string = new \StringJuggler\String('Nullam quis risus eget urna mollis ornare vel eu leo. Vestibulum id ligula porta felis euismod semper. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Vestibulum id ligula porta felis euismod semper. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam porta sem malesuada magna mollis euismod. Vestibulum id ligula porta felis euismod semper. Nullam id dolor id nibh ultricies vehicula ut id elit. Donec id elit non mi porta gravida at eget metus. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Curabitur blandit tempus porttitor. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Etiam porta sem malesuada magna mollis euismod. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Donec id elit non mi porta gravida at eget metus. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Maecenas sed diam eget risus varius blandit sit amet non magna. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.');`

if (($text = $string->getAfter('risus')->getBefore('vel eu')->getTrimmed()) == 'eget urna mollis ornare') {
	.. do something
} else {
	.. do something else
}`
```

All methods
-----------

[](#all-methods)

- after()
- before()
- getAfter()
- getAfterPosition()
- getBefore()
- getBeforePosition()
- getExplode()
- getIReplace()
- getPregMatches()
- getPregReplace()
- getReplace()
- getString()
- getTrimmed()
- ireplace()
- isEmpty()
- isNotEmpty()
- pregMatch()
- pregReplace()
- replace()
- setString()
- trim()

License and attribution
-----------------------

[](#license-and-attribution)

The MIT License (MIT)

Copyright (c) 2015 Christian Johansson

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

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

Total

2

Last Release

2971d ago

### Community

Maintainers

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

---

Top Contributors

[![amostajo](https://avatars.githubusercontent.com/u/1645908?v=4)](https://github.com/amostajo "amostajo (2 commits)")[![cjohansson](https://avatars.githubusercontent.com/u/273325219?v=4)](https://github.com/cjohansson "cjohansson (1 commits)")

---

Tags

phpstringjugglingjuggler

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/10quality-php-string-juggler/health.svg)

```
[![Health](https://phpackages.com/badges/10quality-php-string-juggler/health.svg)](https://phpackages.com/packages/10quality-php-string-juggler)
```

###  Alternatives

[coduo/php-to-string

Simple library that converts PHP value into strings

27112.7M10](/packages/coduo-php-to-string)[lasserafn/php-string-script-language

Detect language/encoding of a string in PHP

204.2M2](/packages/lasserafn-php-string-script-language)[iteks/laravel-enum

A comprehensive Laravel package providing enhanced enum functionalities, including attribute handling, select array conversions, and fluent facade interactions for robust enum management in Laravel applications.

2516.7k](/packages/iteks-laravel-enum)

PHPackages © 2026

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