Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Word Extract Laravel Package

bitandblack/word-extract

Extract and process words from text by minimum length. Get matching words as an array or apply a callback to transform each extracted word within the original string. Simple PHP library installable via Composer.

View on GitHub
Deep Wiki
Context7

PHP from Packagist Total Downloads License

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.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
sentix/ai-chatbot
terminal42/code-quality-tools
codifyo/ts-generator-bundle
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky