1. Go to this page and download the library: Download jakewhiteley/php-sets 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/ */
jakewhiteley / php-sets example snippets
use PhpSets\Set;
$set = new Set(1, 2, 3);
$emptySet = new Set();
// $set contains [1, 2, 3] as duplicates are not stored
$set = new Set(1, 2, 1, 3, 2);
$set = new Set([1, 2, 1, 3, 2]);
$array = [1, 2, 1, 3, 2];
$set = new Set(...$array);
// create empty Set
$set = new Set();
$set->add('a');
// $set => ['a']
$set->add(1);
// $set => ['a', 1]
$set = new Set();
$set[] = 1;
$set[] = 'foo';
// $set => [1, 'foo']
// You can also replace values by key, provided the new value is unique within the Set
$set[0] = 2;
// $set => [2, 'foo']
// If a key is not currently in the array, the value is appended to maintain insertion order
$set[4] = 'foo';
// $newSet => [2, 'foo', 'foo']