PHPackages                             hugsbrugs/php-text - 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. hugsbrugs/php-text

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

hugsbrugs/php-text
==================

PHP Text Utilities

048PHP

Since Jan 22Pushed 5y ago1 watchersCompare

[ Source](https://github.com/hugsbrugs/php-text)[ Packagist](https://packagist.org/packages/hugsbrugs/php-text)[ RSS](/packages/hugsbrugs-php-text/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

php-text
========

[](#php-text)

This librairy provides utilities function to ease text manipulation

[![Build Status](https://camo.githubusercontent.com/35ca78daea3d707b001fc8795b7d6ffe373fe6ba2d31244ef7b619a359ca4c07/68747470733a2f2f7472617669732d63692e6f72672f6875677362727567732f7068702d746578742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/hugsbrugs/php-text)[![Coverage Status](https://camo.githubusercontent.com/a32e76f6c032160d92a7e3ff7793499013d6de606e1ffd5bb55f58c3ab00ec74/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6875677362727567732f7068702d746578742f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/hugsbrugs/php-text?branch=master)

Install
-------

[](#install)

Install package with composer

```
composer require hugsbrugs/php-text

```

In your PHP code, load library

```
require_once __DIR__ . '/../vendor/autoload.php';
use Hug\Text\Text as Text;
```

Usage
-----

[](#usage)

Returns a random extract of a text

```
Text::extract($text, $min_extract_length = 5, $max_extract_length = 10);
```

Removes non breaking spaces from a string

```
Text::remove_non_breaking_spaces($text);
```

Cleans bad UTF-8 chars from text

```
Text::clean_utf8($text);
```

Converts a text into UTF-8

```
Text::convert_to_utf8($text);
```

Fixes curly brackets

```
Text::fix_curly($text);
```

Fixes windows encoding

```
Text::fix_windows_encoding($text);
```

Cleans a text from small sentences

```
Text::remove_sentences($text, $min_phrase_words = 12, $separator = "\n");
```

Extract all emails contained in a text

```
Text::extract_emails($text);
```

Extract first email found in a text

```
Text::extract_first_email($text);
```

Get difference between two texts

```
Text::diff($old, $new);
```

Get difference between two texts in HTML

```
Text::html_diff($old, $new);
```

Guess most propable language from a text using PEAR DetectLanguage

```
Text::get_lang($text, '2');
```

Get all available languages with PEAR DetectLanguage Library

```
$test = Text::get_languages();
```

Remove UTF-8 BOM from text

```
$text_without_bom = Text::remove_utf8_bom($text_with_bom);
```

Remove multiple spaces, tabs and line breaks from text

```
$text_without_spaces = Text::remove_multiple_spaces($text_with_spaces);
```

Author
------

[](#author)

Hugo Maugey [Webmaster](https://hugo.maugey.fr/webmaster) | [Consultant SEO](https://hugo.maugey.fr/consultant-seo) | [Fullstack developer](https://hugo.maugey.fr/developpeur-web)

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity31

Early-stage or recently created project

 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.

### Community

Maintainers

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

---

Top Contributors

[![hugsbrugs](https://avatars.githubusercontent.com/u/4385090?v=4)](https://github.com/hugsbrugs "hugsbrugs (13 commits)")

### Embed Badge

![Health badge](/badges/hugsbrugs-php-text/health.svg)

```
[![Health](https://phpackages.com/badges/hugsbrugs-php-text/health.svg)](https://phpackages.com/packages/hugsbrugs-php-text)
```

###  Alternatives

[spatie/laravel-feed

Generate rss feeds

9743.6M28](/packages/spatie-laravel-feed)

PHPackages © 2026

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