PHPackages                             thomas-squall/string-utils - 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. thomas-squall/string-utils

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

thomas-squall/string-utils
==========================

Utilities for string management

0.5.5(7y ago)12763MITPHP

Since Dec 27Pushed 6y ago1 watchersCompare

[ Source](https://github.com/ThomasSquall/PHPStringUtils)[ Packagist](https://packagist.org/packages/thomas-squall/string-utils)[ RSS](/packages/thomas-squall-string-utils/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (3)Used By (3)

String Utils for php
====================

[](#string-utils-for-php)

List of available functions
---------------------------

[](#list-of-available-functions)

1. [string\_starts\_with](#string_starts_with)
2. [string\_ends\_with](#string_ends_with)
3. [string\_between](#string_between)
4. [strings\_between](#strings_between)
5. [string\_contains](#string_contains)

### string\_starts\_with

[](#string_starts_with)

#### Description

[](#description)

Returns true if the $haystack string starts with the $needle string.

#### Definition

[](#definition)

string\_starts\_with($haystack, $needle)

Where:

1. $haystack is the string to look into
2. $needle is the string to check if the $haystack starts with

#### Usage

[](#usage)

```
$string = "Hello World";

echo "Starts with Hello? " . string_starts_with($string, "Hello");
echo PHP_EOL;
echo "Starts with World? " . string_starts_with($string, "World");
```

This will print:

```
Starts with Hello? true
Starts with World? false
```

### string\_ends\_with

[](#string_ends_with)

#### Description

[](#description-1)

Returns true if the $haystack string ends with the $needle string.

#### Definition

[](#definition-1)

string\_ends\_with($haystack, $needle)

Where:

1. $haystack is the string to look into
2. $needle is the string to check if the $haystack starts with

#### Usage

[](#usage-1)

```
$string = "Hello World";

echo "Ends with Hello? " . string_ends_with($string, "Hello");
echo PHP_EOL;
echo "Ends with World? " . string_ends_with($string, "World");
```

This will print:

```
Ends with Hello? false
Ends with World? true
```

### string\_between

[](#string_between)

#### Description

[](#description-2)

Returns the first occurrence of the string between the $start and $end string from $string. False if nothing is found.

#### Definition

[](#definition-2)

string\_between($string, $start, $end, $empty\_string = false)

Where:

1. $string is the string to look into
2. $start is the left string to search
3. $end is the right string to search
4. $empty\_string determines whether return empty strings or not

#### Usage

[](#usage-2)

```
$string_1 = "|Hello|World|";
$string_2 = "||";

echo "String 1: " . string_between($string_1, "|", "|");
echo PHP_EOL;
echo "String 2 with $empty_string false: " . string_between($string_2, "|", "|");
echo PHP_EOL;
echo "String 2 with $empty_string true: " . string_between($string_2, "|", "|", true);
```

This will print:

```
String 1: Hello
String 2: false
String 2:
```

### strings\_between

[](#strings_between)

#### Description

[](#description-3)

Returns the strings between the $start and $end string from $string. Empty array if nothing is found.

#### Definition

[](#definition-3)

strings\_between($string, $start, $end, $empty\_strings = false)

Where:

1. $string is the string to look into
2. $start is the left string to search
3. $end is the right string to search
4. $empty\_strings determines whether return empty strings or not

#### Usage

[](#usage-3)

```
$string = "|Hello|World||";

echo "With $empty_strings false:" . PHP_EOL;
print_r(strings_between($string, "|", "|"));
echo PHP_EOL;
echo "With $empty_strings true:" . PHP_EOL;
print_r(strings_between($string, "|", "|", true));
```

This will print:

```
With $empty_strings false:
Array ( [0] => Hello [1] => World )

With $empty_strings true:
Array ( [0] => Hello [1] => World [2] => )
```

### string\_contains

[](#string_contains)

#### Description

[](#description-4)

True or false whether the string $needle is contained in the string $haystack or not.

#### Definition

[](#definition-4)

string\_contains($haystack, $needle)

Where:

1. $haystack is the string to look into
2. $needle is the string to check if the $haystack contains

#### Usage

[](#usage-4)

```
$string = "Hello";

echo "Contains Hello? " . string_contains($string, "Hello");
echo PHP_EOL;
echo "Contains World? " . string_contains($string, "World");
```

This will print:

```
Contains Hello? true
Contains World? false
```

More utilities coming
---------------------

[](#more-utilities-coming)

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

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

Total

2

Last Release

2693d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7748020?v=4)[Thomas Cocchiara](/maintainers/ThomasSquall)[@ThomasSquall](https://github.com/ThomasSquall)

---

Top Contributors

[![ThomasSquall](https://avatars.githubusercontent.com/u/7748020?v=4)](https://github.com/ThomasSquall "ThomasSquall (7 commits)")

---

Tags

phpstring-manipulationstringsutilsutils-library

### Embed Badge

![Health badge](/badges/thomas-squall-string-utils/health.svg)

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

###  Alternatives

[zservices/query

Pacote para consultas em serviços do governo.

131.1k](/packages/zservices-query)

PHPackages © 2026

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