| Recommend this page to a friend! |
| Info | Documentation | Reputation | Support forum | Blog | Links |
| Ratings | Unique User Downloads | Download Rankings | ||||
| Not enough user ratings | Total: 210 | All time: 8,376 This week: 34 | ||||
| Version | License | PHP version | Categories | |||
| sanitize_string 1.3 | The PHP License | 5.6 | PHP 5, Files and Folders, Text proces... |
Sometimes you may want to clean a filename or string from foreign languages characters; with this class you can do both.
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.
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);
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.
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.
| File | Role | Description |
|---|---|---|
| Data | Auxiliary data | |
| Lic. | MIT License | |
| Doc. | Documentation | |
| Class | Class source |
| The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. |
| Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
| 100% |
|
|
| User Comments (1) | |||||
| |||||
| Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.