PHP code example of elegantmedia / php-toolkit

1. Go to this page and download the library: Download elegantmedia/php-toolkit 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/ */

    

elegantmedia / php-toolkit example snippets


composer 
 php
use \ElegantMedia\PHPToolkit\Arr;

// Check if an array is an associative array
Arr::isAssoc($array);

// get matching subset of array. Similar to `array_intersect`, but does recursively.
Arr::intersectRecursive($source, $subset);

// Implode, but exclude empty values
Arr::implodeIgnoreEmpty($glue, $array);

// Sway a key on an associative array
Arr::swapKey($array, $oldKey, $newKey, $recursive = false);

// Key values of an array to another key
Arr::keyBy($array, $key);
 php
use \ElegantMedia\PHPToolkit\Path;

Path::withEndingSlash($path);
Path::withStartingSlash($path);
Path::withoutEndingSlash($path);
Path::withoutStartingSlash($path);

// remove dot segments from paths
// Example: Convert `/folder1/folder2/./../folder3` to `/folder1/folder3`
Path::canonical($path);