PHPackages                             andydune/custom-string-explode - 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. andydune/custom-string-explode

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

andydune/custom-string-explode
==============================

Explode string using custom user rules.

v1.3.0(7y ago)0336MITPHPPHP &gt;=5.6CI failing

Since Jul 21Pushed 5y ago1 watchersCompare

[ Source](https://github.com/AndyDune/CustomStringExplode)[ Packagist](https://packagist.org/packages/andydune/custom-string-explode)[ Docs](https://github.com/AndyDune/CustomStringExplode)[ RSS](/packages/andydune-custom-string-explode/feed)WikiDiscussions master Synced 4d ago

READMEChangelog (7)Dependencies (1)Versions (8)Used By (0)

CustomStringExplode
===================

[](#customstringexplode)

[![Build Status](https://camo.githubusercontent.com/0fac71d5bc6c76796b63d5ebe343b58d35d069cc5830131253f15e4c8522b6ab/68747470733a2f2f7472617669732d63692e6f72672f416e647944756e652f437573746f6d537472696e674578706c6f64652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/AndyDune/CustomStringExplode)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Packagist Version](https://camo.githubusercontent.com/4efa5af88f84c0fa6186939a5491e1a82a4c170b4c2f8fe091b23dfd9eeb0a20/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616e647964756e652f637573746f6d2d737472696e672d6578706c6f64652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/andydune/custom-string-explode)[![Total Downloads](https://camo.githubusercontent.com/72cd2b5b487cd20df1945e3f5a86b89fad22f31a70e44bd0454353d3c3248b98/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616e647964756e652f637573746f6d2d737472696e672d6578706c6f64652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/andydune/custom-string-explode)

Explode string using user custom rules.

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

[](#installation)

Installation using composer:

```
composer require andydune/custom-string-explode

```

Or if composer was not installed globally:

```
php composer.phar require andydune/custom-string-explode

```

Or edit your `composer.json`:

```
"require" : {
     "andydune/custom-string-explode": "^1"
}

```

And execute command:

```
php composer.phar update

```

Instruction
-----------

[](#instruction)

There is any string we want to convert into array. String may be set of numbers with any delimiters, it can be email set and more.

It is better to see how it works for on specific points.

Rule: Numbers
-------------

[](#rule-numbers)

```
use AndyDune\CustomStringExplode\Rule\Numbers;
use AndyDune\CustomStringExplode\StringContainer;

$numbers = new Numbers();
$explode = new StringContainer($numbers);
$results = $explode->explode('123 13-4 00');

// Result is
$result = [123, 13, 4, 00];
```

Rule: Emails
------------

[](#rule-emails)

```
use AndyDune\CustomStringExplode\Rule\Email;
use AndyDune\CustomStringExplode\StringContainer;

$rule = new Email();
$explode = new StringContainer($rule);

$results = $explode->explode('Андрей Рыжов,  ;
Andrey Ryzhov,
simple@example.com ,
disposable.style.email.with+symbol@example.com
x@example.com
#!$%&\'*+-/=?^_`{}|~@example.org
"()[]:,;@\\\"!#$%&\'-/=?^_`{}| ~.a"@example.org
');

// Result is
$result = [
    'simple@example.com',
    'disposable.style.email.with+symbol@example.com',
    'x@example.com',
    '#!$%&'*+-/=?^_`{}|~@example.org'
];
```

Rule: NumbersAndLatinLetters
----------------------------

[](#rule-numbersandlatinletters)

I used it for extract hashes from any texts.

```
use AndyDune\CustomStringExplode\StringContainer;
use AndyDune\CustomStringExplode\Rule\NumbersAndLatinLetters;

$rule = new NumbersAndLatinLetters();
$explode = new StringContainer($rule);

$results = $explode->explode('adqwdqw123 adasdsa;78
првиетhellow
');

// Result is
$result = [
    'adqwdqw123',
    'adasdsa',
    '78',
    'hellow'
];
```

Rule: DelimiterWhitespaceCharacter
----------------------------------

[](#rule-delimiterwhitespacecharacter)

It helps to explode string with any white space delimiter.

```
use AndyDune\CustomStringExplode\Rule\DelimiterWhitespaceCharacter;
use AndyDune\CustomStringExplode\StringContainer;
$rule = new DelimiterWhitespaceCharacter();
$explode = new StringContainer($rule);

$results = $explode->explode('123 13-4 00');

// Result is
$result = [
    '123',
    '13-4',
    '00'
];
```

Create custom rules
-------------------

[](#create-custom-rules)

You may build your onw rules for explode strings as you wish. All rules mast implement `RuleAbstract` interface.

Lets look at the code:

```
namespace AndyDune\CustomStringExplode\Rule;
use AndyDune\CustomStringExplode\StringContainer;

abstract class RuleAbstract
{
    /**
     * @var StringContainer
     */
    protected $container;

    /**
     * @return StringContainer
     */
    public function getContainer()
    {
        return $this->container;
    }

    /**
     * @param StringContainer $container
     */
    public function setContainer($container)
    {
        $this->container = $container;
    }

    public function format($string)
    {
        return trim($string);
    }

    /**
    * @params string $char current char for check
    * @params string $item previously collected char
    * @params array $array array was colected during previous executions of method
    */
    abstract public function check($char, $item, $array);
}
```

You need to define method `check` surely. This method returns boolean value:

- `true` - current char may be the part of string
- `false` - current char is separator

Overload method `format` for final check every result array item. It make trim by default. Method may returns `null` or `false` if item must be deleted from array.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

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

Total

7

Last Release

2795d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/79da3b2173a2cefb36abc9b4707cf2c633df8f2c748633ccf64186f5c0e7be6c?d=identicon)[AndyDune](/maintainers/AndyDune)

---

Top Contributors

[![AndyDune](https://avatars.githubusercontent.com/u/3772910?v=4)](https://github.com/AndyDune "AndyDune (16 commits)")

---

Tags

php

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/andydune-custom-string-explode/health.svg)

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

###  Alternatives

[imanghafoori/laravel-anypass

A minimal yet powerful package to help you in development.

21421.6k](/packages/imanghafoori-laravel-anypass)

PHPackages © 2026

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