bitandblack/word-extract

Extract or handle words with a given minimum length.

Package info

github.com/BitAndBlack/word-extract

Homepage

pkg:composer/bitandblack/word-extract

Fund package maintenance!

Buymeacoffee

Statistics

Installs: 456

Dependents: 1

Suggesters: 0

Stars: 1

Open Issues: 0

1.3.1 2026-04-10 20:03 UTC

Requires

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT fb98d7002cd5c76374509f83d4da64c8d92c2906

This package is auto-updated.

Last update: 2026-06-10 20:22:34 UTC


README

👁 PHP from Packagist
👁 Total Downloads
👁 License

👁 Bit&Black Logo

Bit&Black Word Extract

Extract or handle words with a given minimum length.

Installation

This library is written in PHP and made for the use with Composer. Be sure to have both of them installed on your system.

Add the library then to your project by running $ composer require bitandblack/word-extract.

Usage

Initialise the WordExtractor class with the minimum number of letters that the words to be extracted should have:

<?php

use BitAndBlack\WordExtract\WordExtractor;

$wordExtractor = new WordExtractor(10);

Extract the words from a given string then:

<?php

$sentence = 'Herzlich willkommen in meinem Rosengarten';

$words = $wordExtractor->getWords($sentence);

/**
 * This will dump
 * 
 * array(2) {
 * [0]=> string(10) "willkommen"
 * [1]=> string(11) "Rosengarten"
 * }
 */
var_dump($words);

Or use a callback to handle each of the extracted words:

<?php

$sentence = 'Herzlich willkommen in meinem Rosengarten';

$handler = static function (string $word): string {
 return '[' . $word . ']';
};

$sentenceHandled = $wordExtractor->getWithWordsHandled($sentence, $handler);

/**
 * This will dump
 * 
 * string(45) "Herzlich [willkommen] in meinem [Rosengarten]"
 */
var_dump($sentenceHandled);

Help

If you have any questions feel free to contact us under hello@bitandblack.com.

Further information about Bit&Black can be found under www.bitandblack.com.