hugsbrugs/php-text

There is no license information available for the latest version (dev-master) of this package.

PHP Text Utilities

dev-master 2021-01-22 09:49 UTC

This package is auto-updated.

Last update: 2024-04-22 16:50:28 UTC


README

This librairy provides utilities function to ease text manipulation

Build Status Coverage Status

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