PHPackages                             lkt/tools - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. lkt/tools

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

lkt/tools
=========

LKT PHP Tools

2.0.6(6mo ago)03968MITPHPPHP &gt;=8.1.0

Since Feb 22Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/lkt-php/lkt-tools)[ Packagist](https://packagist.org/packages/lkt/tools)[ RSS](/packages/lkt-tools/feed)WikiDiscussions v2.0 Synced 4w ago

READMEChangelog (9)Dependencies (2)Versions (21)Used By (8)

LKT Tools
=========

[](#lkt-tools)

Array tools
-----------

[](#array-tools)

### arrayAverage

[](#arrayaverage)

Returns the AVG value from a numeric array

ArgTypeDescription$arraynumber\[\]Input numbers#### Usage

[](#usage)

```
\Lkt\Tools\Arrays\arrayAverage([5, 5]); // Will return 5
\Lkt\Tools\Arrays\arrayAverage([7, 3]); // Will return 5
```

### arrayPushUnique

[](#arraypushunique)

Push an item to an array if not exists yet

ArgTypeDescription$arrayany\[\]Array$datumanyAny datum to be added#### Usage

[](#usage-1)

```
$array = [1, 3];
\Lkt\Tools\Arrays\arrayPushUnique($array, 2); // Array content: [1, 3, 2]
\Lkt\Tools\Arrays\arrayPushUnique($array, 3); // Array content: [1, 3, 2]
\Lkt\Tools\Arrays\arrayPushUnique($array, 4); // Array content: [1, 3, 2, 4]
```

### arrayKeyPushUnique

[](#arraykeypushunique)

Adds a key to an array only if not defined yet

ArgTypeDescription$arrayany\[\]Array$keystringArray key$datumanyAny datum to be added#### Usage

[](#usage-2)

```
$array = ['one' => 1, 'three' => 3];
\Lkt\Tools\Arrays\arrayKeyPushUnique($array, 'two', 2); // Array content: ['one' => 1, 'three' => 3, 'two' => 2]
\Lkt\Tools\Arrays\arrayKeyPushUnique($array, 'three', 6); // Array content: ['one' => 1, 'three' => 3, 'two' => 2]
\Lkt\Tools\Arrays\arrayKeyPushUnique($array, 'four', 4); // Array content: ['one' => 1, 'three' => 3, 'two' => 2, 'four' => 4]
```

### arrayRemoveDatum

[](#arrayremovedatum)

Finds data in an array and removes it.

If it's a numeric indexed array, it will reset indexes

ArgTypeDescription$arrayany\[\]Array$datumanyAny datum to be removed#### Usage

[](#usage-3)

```
$array = ['one' => 1, 'three' => 3];
\Lkt\Tools\Arrays\arrayRemoveDatum($array, 1); // Array content: ['three' => 3]
```

### arrayValuesRecursive

[](#arrayvaluesrecursive)

Converts input array and array properties to one single array with all properties inside

ArgTypeDescription$arrayany\[\]Array#### Usage

[](#usage-4)

```
$array = ['test' => 'Test', 'test2'=> ['a' => 'A', 'b' => 'B']];
\Lkt\Tools\Arrays\arrayValuesRecursive($array, 1); // Array content: ['Test', 'A', 'B']
```

### arrayValuesRecursiveWithKeys

[](#arrayvaluesrecursivewithkeys)

Same as `arrayValuesRecursive` but keeping a key structure

ArgTypeDescription$arrayany\[\]Array#### Usage

[](#usage-5)

```
$array = ['test' => 'Test', 'test2'=> ['a' => 'A', 'b' => 'B']];
\Lkt\Tools\Arrays\arrayValuesRecursiveWithKeys($array, 1); // Array content: ['test' => 'Test', 'test2.a' => 'A', 'test2.b' => 'B']
```

### compareArrays

[](#comparearrays)

Compares two arrays and determine which keys were added and/or removed

ArgTypeDescription$array1any\[\]Array$array2any\[\]Array#### Usage

[](#usage-6)

```
$arr1 = [1, 2, 3];
$arr2 = [1, 2, 4];

\Lkt\Tools\Arrays\compareArrays($arr1, $arr2); // Result: ['added' => [4], 'deleted' => [3]]
```

### getArrayFirstPosition

[](#getarrayfirstposition)

Returns the first element in an array no matter if it has numeric or string indexes

ArgTypeDescription$arrayany\[\]Array#### Usage

[](#usage-7)

```
$array = [1, 2, 3];

\Lkt\Tools\Arrays\getArrayFirstPosition($array); // Result: 1
```

### implodeWithAND

[](#implodewithand)

Implodes array elements with `AND` string

ArgTypeDescription$arrayany\[\]Array#### Usage

[](#usage-8)

```
$array = [1, 2, 3];

\Lkt\Tools\Arrays\implodeWithAND($array); // Result: '1 AND 2 AND 3'
```

### implodeWithOR

[](#implodewithor)

Implodes array elements with `OR` string

ArgTypeDescription$arrayany\[\]Array#### Usage

[](#usage-9)

```
$array = [1, 2, 3];

\Lkt\Tools\Arrays\implodeWithOR($array); // Result: '1 OR 2 OR 3'
```

Color
-----

[](#color)

### decToHex

[](#dectohex)

Converts a rgb color into hexadecimal string

ArgTypeDescription$color\[int, int int\]A 3 values array containing (red, green, blue) values#### Usage

[](#usage-10)

```
\Lkt\Tools\Color\decToHex([255, 255, 255]); // Result: #ffffff
\Lkt\Tools\Color\decToHex([255, 255, 0]); // Result: #ffff00
```

### hexToDec

[](#hextodec)

Converts a hexadecimal color into rgb array

ArgTypeDescription$colorstringA valid hexadecimal string color#### Usage

[](#usage-11)

```
\Lkt\Tools\Color\hexToDec('#ffffff'); // Result: [255, 255, 255]
\Lkt\Tools\Color\hexToDec('#ffff00'); // Result: [255, 255, 0]
```

Pagination
----------

[](#pagination)

### getTotalPages

[](#gettotalpages)

Calculate the max number of pages

ArgTypeDescription$amountOfItemsintAmount of elements to paginate$itemsPerPageintMax elements shown per page#### Usage

[](#usage-12)

```
\Lkt\Tools\Pagination\getTotalPages(9, 5); // Result: 2
\Lkt\Tools\Pagination\getTotalPages(11, 5); // Result: 3
```

Parse
-----

[](#parse)

### clearInput

[](#clearinput)

Sanitizes an input string

ArgTypeDescription$valuestringDatum#### Usage

[](#usage-13)

```
\Lkt\Tools\Parse\clearInput('   \Hello world'); // Result: 'Hello world'
```

### removeDuplicatedWitheSpices

[](#removeduplicatedwithespices)

Removes all duplicated withe spaces and replace it with a single space

ArgTypeDescription$valuestringDatum#### Usage

[](#usage-14)

```
\Lkt\Tools\Parse\removeDuplicatedWitheSpices('Hello     world'); // Result: 'Hello world'
```

###  Health Score

44

—

FairBetter than 90% of packages

Maintenance66

Regular maintenance activity

Popularity13

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~94 days

Recently: every ~33 days

Total

20

Last Release

207d ago

Major Versions

v1.2.x-dev → 2.0.02022-12-22

PHP version history (2 changes)1.0.0PHP &gt;=7.2.0

2.0.0PHP &gt;=8.1.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/456537?v=4)[Gediminas Aleknavičius](/maintainers/lkt)[@lkt](https://github.com/lkt)

---

Top Contributors

[![alphaibanez](https://avatars.githubusercontent.com/u/24976472?v=4)](https://github.com/alphaibanez "alphaibanez (19 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/lkt-tools/health.svg)

```
[![Health](https://phpackages.com/badges/lkt-tools/health.svg)](https://phpackages.com/packages/lkt-tools)
```

###  Alternatives

[rs/laravel-version-control

Foundations for making your app version controlled. Provides migration, blueprint and base models. Will make your app GxP compliant if you exclusively use the VC models and table structure as set out in this package.

1228.0k](/packages/rs-laravel-version-control)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
