hugsbrugs / php-text
PHP Text Utilities
Requires
- hugsbrugs/text-language-detect: dev-master
- neitanod/forceutf8: dev-master
This package is auto-updated.
Last update: 2024-12-22 18:23:10 UTC
README
This librairy provides utilities function to ease text manipulation
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
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
Hugo Maugey Webmaster | Consultant SEO | Fullstack developer