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

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

elphis/string-helpers
=====================

Useful string helper functions for php.

v1.0(6y ago)311MITPHPPHP ^7.0CI failing

Since Apr 9Pushed 5y ago2 watchersCompare

[ Source](https://github.com/elphis-io/elphis-string-helpers)[ Packagist](https://packagist.org/packages/elphis/string-helpers)[ RSS](/packages/elphis-string-helpers/feed)WikiDiscussions master Synced 1w ago

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

Elphis String Helpers
=====================

[](#elphis-string-helpers)

This library contains some basic php helpers that will make manipulating strings easier and better. Every function in this library is namespaced Elphis\\Helpers\\Str to avoid conflicts with any other library you might be using.

### Installation

[](#installation)

```
composer require elphis/string-helpers:dev-master

```

### Below is the list of string helpers this package provides.

[](#below-is-the-list-of-string-helpers-this-package-provides)

- **str\_contains($haystack, $needle, $caseInsensitive = false):**checks if the **$needle** string is present in **$haystack** string and returns *true* or *false* accordingly. When **$casInsensitive** is *true* the check will be as the name says, case insensitive.

```
    Eg:
    $fullName   = 'John Joseph Doe';
    $fatherName = 'Joseph';
    str_contains($fullName, $fatherName); // *true*
    $fatherName = 'joseph';
    str_contains($fullName, $fatherName); // *false*
    str_contains($fullName, $fatherName, true); // *true*

```

- **str\_equals($string1, $string2, $caseInsensitive = false):**checks if the given string are equal. When **$caseInsensitive** is true the check will be case insensitive.

```
    Eg:
    $string1 = 'In the bleak mid-winter';
    $string2 = 'In the bleak mid-winter';
    str_equals($string1, $string2); // *true*
    $string2 = 'In the bleak MID-WINTER';
    str_equals($string1, $string2); // *false*
    str_equals($string1, $string2, true); // *true*

```

- **str\_starts\_with($haystack, $needle, $caseInsensitive = false):**checks if the given **$haystack** string starts with the given **$needle**. **$caseInsensitive** = *true* for case insensitive check.

```
    Eg:
    $fullName  = 'John Joseph Doe';
    $firstName = 'John';
    str_starts_with($fullName, $firstName); // *true*
    $firstName = 'john';
    str_starts_with($fullName, $firstName); // *false*
    str_starts_with($fullName, $firstName, true); // *true*
    $firstName = 'joseph';
    str_starts_with($fullName, $firstName); // *false*
    str_starts_with($fullName, $firstName, true); // *false*

```

- **str\_ends\_with($haystack, $needle, $caseInsensitive = false):**checks if the given **$haystack** string ends with the given **$needle**. **$caseInsensitive** = *true* for case insensitive check.

```
    Eg:
    $fullName = 'John Joseph Doe';
    $lastName = 'Doe';
    str_ends_with($fullName, $lastName); // *true*
    $lastName = 'doe';
    str_ends_with($fullName, $lastName); // *false*
    str_ends_with($fullName, $lastName, true); // *true*
    $lastName = 'joseph';
    str_ends_with($fullName, $lastName); // *false*
    str_ends_with($fullName, $lastName, true); // *false*

```

- **str\_limit($string, $length, $suffix = '...'):**this function limits/splice the **$string** at the given **$length** and suffixes it with the given **$suffix**.

```
    Eg:
    $title = 'This is a very long string that cannot be displayed in the list section of your blog, so you have to limit it.';
    str_limit($title, 20); // *This is a very long ...*
    str_limit($title, 20, '---'); // *This is a very long ---*

```

- **str\_after($haystack, $needle, bool $caseInsensitive = false):**returns the string after **$needle** from **$haystack**. When **$caseSensitive** = *true*, **$needle** will be searched case insensitively.

```
    Eg:
    $title = 'This is a very long string that cannot be displayed in the list section of your blog, so you have to break it.';
    str_after($title, 'This is a very long string that cannot be displayed'); // *in the list section of your blog, so you have to break it.*
    str_after($title, 'Yolo'); // *''*
    str_after($title, 'this'); // *''*
    str_after($title, 'this', true); // *is a very long string that cannot be displayed in the list section of your blog, so you have to break it.*

```

- **str\_before($haystack, $needle, bool $caseInsensitive = false):**returns the string before **$needle** from **$haystack**. When **$caseSensitive** = *true*, **$needle** will be searched case insensitively.

```
    Eg:
    $title = 'This is a very long string that cannot be displayed in the list section of your blog, so you have to break it.';
    str_before($title, 'a very long'); // *This is *
    str_before($title, 'Yolo'); // *''*
    str_before($title, 'this'); // *''*
    str_before($title, 'this', true); // *''*
    str_before($title, 'is a very', true); // *This *

```

- **str\_between(string $haystack, string $from, string $to, bool $caseInsensitive = false):**returns the string found between the given **$from** sub-string and **$to** sub-string from the given **$haystack**. When **$caseInsensitive** = *true*, **$from** and **$to** will be searched case insensitively.

```
    Eg:
    $title = 'This is a very long string that cannot be displayed in the list section of your blog, so you have to break it.';
    str_between($title, 'This', 'long'); // * is a very *
    str_between($title, 'is', 'This'); // *''*
    str_between($title, 'is', 'This', true); // *''*
    str_between($title, 'this', 'is', true); // *' is a very '*
    str_between($title, 'sO YoU hAve', 'it', true); // *' to break '*

```

- **str\_strip\_special\_chars(string $string, string $replaceWith = ''):**strips the given **$string** of any special characters and returns a string containing only alphabets, or numbers. Passing **$replaceWith** will replace the special chars in the string with **$replaceWith**.

```
    Eg:
    $title = '^&%This*&(*is)(^%^#@_=0it.';
    str_strip_special_chars($title); // *Thisis0it*
    str_strip_special_chars($title, '-'); // *---This----is---------0it-*

```

- **str\_camel\_case($string):**strips the given **$string** of any special character and spaces, and turns **$string** into "CamelCase".

```
    Eg:
    $title = 'This is a normal string';
    str_camel_case($title); // *thisIsANormalString*
    $title = 'This is$a#normal%string';
    str_camel_case($title); // *thisIsANormalString*

```

- **str\_studly\_case($string):**strips the given **$string** of any special character and spaces, and turns it into "studlyCase".

```
    Eg:
    $title = 'This is a normal string';
    str_studly_case($title); // *ThisIsANormalString*
    $title = 'This is$a#normal%string';
    str_studly_case($title); // *ThisIsANormalString*

```

- **str\_kebab\_case($string):**strips the given **$string** of any special character and spaces, and turns it into "kebab-case".

```
    Eg:
    $title = 'This is a normal string';
    str_kebab_case($title); // *this-is-a-normal-string*
    $title = 'This is$a#normal%string';
    str_kebab_case($title); // *this-is-a-normal-string*

```

- **str\_snake\_case($string):**strips the given **$string** of any special character and spaces, and turns it into "snake\_case". strips the given **$string** of any special character and spaces, and turns it into "kebab-case".

```
    Eg:
    $title = 'This is a normal string';
    str_snake_case($title); // *this_is_a_normal_string*
    $title = 'This is$a#normal%string';
    str_snake_case($title); // *this_is_a_normal_string*

```

- **str\_strip\_numbers($string):**removes any numeric values found in **$string**. strips the given **$string** of any special character and spaces, and turns it into "kebab-case".

```
    Eg:
    $title = 'great here is my contact no: 12346732';
    str_strip_numbers($title); // *great here is my contact no:*

```

- **str\_chunks($string, $length = 100):**breaks the given **$string** at every **$length**, and returns an array of string each containing string of **$length**.

```
    Eg:
    $title = 'hope ya'll like this small helper library';
    str_chunk($title, 10); // *['hope ya'll', ' like this', ' small hel', 'per librar', 'y']:*

```

\##Todo ### Add multi byte support. ### Add Wrapper classes around helper functions.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 58.8% 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

Unknown

Total

1

Last Release

2230d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/32874466?v=4)[Saud Jameel Qureshi](/maintainers/SaudQureshi1997)[@SaudQureshi1997](https://github.com/SaudQureshi1997)

---

Top Contributors

[![vamaship-saud-qureshi](https://avatars.githubusercontent.com/u/65214063?v=4)](https://github.com/vamaship-saud-qureshi "vamaship-saud-qureshi (10 commits)")[![SaudQureshi1997](https://avatars.githubusercontent.com/u/32874466?v=4)](https://github.com/SaudQureshi1997 "SaudQureshi1997 (4 commits)")[![ordago](https://avatars.githubusercontent.com/u/6376814?v=4)](https://github.com/ordago "ordago (3 commits)")

---

Tags

phphelperstringhelpersfluentstrusefulcontains

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[pragmarx/ia-str

Laravel Illuminate Agnostic Str

523.5M5](/packages/pragmarx-ia-str)[zjkal/time-helper

一个简单快捷的PHP日期时间助手类库。 a smart PHP datetime helper library.

21128.6k1](/packages/zjkal-time-helper)[clausnz/php-helpers

A Collection of useful php helper functions.

388.7k](/packages/clausnz-php-helpers)[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)[bayfrontmedia/php-array-helpers

Helper class to provide useful array functions.

1413.4k23](/packages/bayfrontmedia-php-array-helpers)

PHPackages © 2026

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