PHP code example of lkt / tools

1. Go to this page and download the library: Download lkt/tools library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

lkt / tools example snippets


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

$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]

$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]

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


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


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


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

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


$array = [1, 2, 3];

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


$array = [1, 2, 3];

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


$array = [1, 2, 3];

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

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

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

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

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

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