PHPackages                             celestial/lexicology - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Search &amp; Filtering](/categories/search)
4. /
5. celestial/lexicology

ActiveLibrary[Search &amp; Filtering](/categories/search)

celestial/lexicology
====================

PHP Lexicology library.

0.0.3(8y ago)116Apache-2.0PHPPHP &gt;= 5.5.0

Since Aug 22Pushed 8y ago1 watchersCompare

[ Source](https://github.com/Celest/lexicology)[ Packagist](https://packagist.org/packages/celestial/lexicology)[ RSS](/packages/celestial-lexicology/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

[![Build Status](https://camo.githubusercontent.com/30657881361fb516a6876387bbd19119a8d646904009c81212e8151450eebe8c/68747470733a2f2f7472617669732d63692e6f72672f43656c6573742f6c657869636f6c6f67792e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Celest/lexicology)

Lexicology
==========

[](#lexicology)

PHP lexicology library.

> While we only test PHP 7+, this library does work with PHP 5.x. PHP Sorting methods changed how they deal with equal sort values in 7+ - so suggestion arrays will differ.

- Suggests values from an array based on a lexical comparison
- Return sorted array based on lexical comparison
- Pick best match from an array
- Pick best match associations between arrays

Core Lexical Comparisons
------------------------

[](#core-lexical-comparisons)

- [levenshtein](http://php.net/manual/en/function.levenshtein.php) using `LevenshteinDistance`
- [preg\_grep](http://php.net/manual/en/function.preg_grep.php) using `PregGrep`
- [similar\_text](http://php.net/manual/en/function.similar_text.php) using `Similarity`
- [soundex](http://php.net/manual/en/function.sounded.php) using `Soundex`

Also allows custom lexical comparison by extending `Celestial\Lexicology\Method\AbstractMethod` and implementing `Celestial\Lexicology\Method\MethodInterface`. See [Custom Method](#custom-method)

Install
-------

[](#install)

Composer

```
composer require celestial\lexicology
```

or composer.json

```
{
   "require": {
       "celestial/lexicology": "^0.1"
   }
}
```

Use
---

[](#use)

### Suggestion

[](#suggestion)

The `Suggestion` class will suggest an array or value that match closely to a needle. The default method is [PregGrep](#PregGrep) but that can be changed to one of the other methods or a custom method.

```
