1. Go to this page and download the library: Download hintik/collection 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/ */
use Hintik\Collection\Lists\MutableArrayList;
$list = MutableArrayList::fromArray([1, 2, 3]);
$list->add(4); // append
$list->addToIndex(1, 99); // insert at index 1
$list->addAll($other); // append all from another collection
$list->set(0, 10); // replace at index
$list->removeIndex(1); // remove by index
$list->remove(99); // remove by value
$list->removeAll($other); // remove all matching
$list->sort(fn($a, $b) => $a <=> $b); // sort in place
$list->reverse(); // reverse in place
$list->clear();
use Hintik\Collection\Map\MutableArrayMap;
$map = MutableArrayMap::fromEmpty();
$map->put('a', 1); // returns previous value or null
$map->putAll($other); // copies all entries from another map
$map->putIfAbsent('a', 9); // only adds if key not present
$map->remove('a'); // returns removed value or null
$map->sort(fn($a, $b) => $a <=> $b); // sort by value in place
$map->clear();
use Hintik\Collection\Set\HashSet;
$set = HashSet::fromArray([1, 2, 3, 2, 1]); // duplicates dropped → {1, 2, 3}
$set->contains(2); // true
$set->size(); // 3
// Set operations (return new set)
$union = $set->union($other); // all elements from both
$inter = $set->intersect($other); // elements in both
$diff = $set->diff($other); // elements in $set but not in $other
// Functional
$even = $set->filter(fn($v) => $v % 2 === 0);
$set->any(fn($v) => $v > 2);
$set->all(fn($v) => $v > 0);
$set->none(fn($v) => $v > 10);
// Iteration
foreach ($set as $item) { /* ... */ }
$set->foreach(fn($item) => print($item));
use Hintik\Collection\Set\MutableHashSet;
$set = MutableHashSet::fromEmpty();
$set->add(1); // returns true if added, false if already present
$set->remove(1); // returns true if removed, false if not present
$set->clear();