PHPackages                             vgd/sanitize\_string - 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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. vgd/sanitize\_string

ActivePackage[Validation &amp; Sanitization](/categories/validation)

vgd/sanitize\_string
====================

Sometimes you may want to clean a filename or string from foreign languages characters; with this class you can do both

1.3(5y ago)4381MITPHPPHP &gt;=5.6

Since Aug 3Pushed 5y ago1 watchersCompare

[ Source](https://github.com/Claw-Hammer/sanitize_string)[ Packagist](https://packagist.org/packages/vgd/sanitize_string)[ Docs](https://github.com/Claw-Hammer/sanitize_string)[ RSS](/packages/vgd-sanitize-string/feed)WikiDiscussions master Synced 6d ago

READMEChangelog (1)DependenciesVersions (3)Used By (0)

Sanitize String Class
=====================

[](#sanitize-string-class)

[![Version](https://camo.githubusercontent.com/033e983e467e0879b8a237ba06eb87dc4cdbff35d56e47cf6646b4a68312ffdc/68747470733a2f2f706f7365722e707567782e6f72672f7667642f73616e6974697a655f737472696e672f76657273696f6e)](//packagist.org/packages/vgd/sanitize_string) [![Total Downloads](https://camo.githubusercontent.com/c4a0fb50741d33d69302a81ecda02fa76590971cd45605ac9566c12013388eb1/68747470733a2f2f706f7365722e707567782e6f72672f7667642f73616e6974697a655f737472696e672f646f776e6c6f616473)](//packagist.org/packages/vgd/sanitize_string) [![Latest Unstable Version](https://camo.githubusercontent.com/d65541d7e716f6b1e5e5f1a7eb4dfa35867c548caeb645daeef066bc8632b629/68747470733a2f2f706f7365722e707567782e6f72672f7667642f73616e6974697a655f737472696e672f762f756e737461626c65)](//packagist.org/packages/vgd/sanitize_string) [![License](https://camo.githubusercontent.com/086d719eb54f512c1353c17ea3bf6c617e664750c0f2da68646ea529d68d3741/68747470733a2f2f706f7365722e707567782e6f72672f7667642f73616e6974697a655f737472696e672f6c6963656e7365)](//packagist.org/packages/vgd/sanitize_string)

Sometimes you may want to clean a filename or string from foreign languages characters; with this class you can do both.

Usage
-----

[](#usage)

```
Install via composer:

composer require vgd/sanitize_string

or

require('SanitizeString.php');

The class uses two boolean parameters after the string/filename:

The first one (isFileName) is used to tell the class that you are trying to clean a file name.

The second one (special) must be used if you would like to remove special characters as well from a
string or a file name.

```

### In order to clean a string:

[](#in-order-to-clean-a-string)

```
To remove foreign characters only:

echo SanitizeString::clean('Your string here');

To remove foreign AND special characters:

echo SanitizeString::clean('Your string here', false, true);

```

### In order to clean a filename:

[](#in-order-to-clean-a-filename)

```
To remove foreign characters only:

SanitizeString::clean('Your filename here', true, false);

To remove foreign AND special characters:

SanitizeString::clean('Your filename here', true, true);

You can use absolute or relative paths for the file you want to rename.

```

### Final Note

[](#final-note)

```
The main purpose of using associative arrays and not other techniques as regular
expressions and preg_match etc. was to give the user the possibility of add or remove
characters depending of their needs.

Lets say that you have a spanish text and you want to remove all the characters but vowels
with tilde and ñ characters; you can modify the arrays to achieve that.

```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity51

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

Unknown

Total

1

Last Release

2113d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5036315?v=4)[clawhammer](/maintainers/clawhammer)[@clawhammer](https://github.com/clawhammer)

---

Top Contributors

[![Claw-Hammer](https://avatars.githubusercontent.com/u/5170633?v=4)](https://github.com/Claw-Hammer "Claw-Hammer (9 commits)")

---

Tags

cleangrammasphpreplacesanitizestring-manipulationcleangrammarsanitizereplaceforeign

### Embed Badge

![Health badge](/badges/vgd-sanitize-string/health.svg)

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

###  Alternatives

[stevebauman/purify

An HTML Purifier / Sanitizer for Laravel

5325.6M19](/packages/stevebauman-purify)[abcaeffchen/sepa-utilities

SepaUtilities provides useful methods for validating and sanitizing inputs used in SEPA files supporting PHP &gt;= 8.1.

312.0M2](/packages/abcaeffchen-sepa-utilities)[mathiasreker/php-svg-optimizer

php-svg-optimizer is a PHP library designed to optimize SVG files by applying various transformations and cleanup operations.

338.9k2](/packages/mathiasreker-php-svg-optimizer)[surgiie/transformer

A data transforming/formatting package for php.

12724.3k1](/packages/surgiie-transformer)[ondrej-vrto/php-filename-sanitize

Removes all forbidden characters from the file name or path.

1120.6k1](/packages/ondrej-vrto-php-filename-sanitize)[erlandmuchasaj/sanitize

A package to sanitize your input.

146.0k](/packages/erlandmuchasaj-sanitize)

PHPackages © 2026

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