PHP code example of salient / collections
1. Go to this page and download the library: Download salient/collections 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/ */
salient / collections example snippets
// The constructor accepts any iterable, including another collection
$foo = new \Salient\Collection\Collection(['foo']);
// Items can be added using array syntax
$foo[] = 'bar';
// Otherwise, the collection is immutable
$foo = $foo->add('baz');
// 'qux' is printed but the collection is unchanged because the result of the
// expression is discarded
$foo->unshift('qux')->sort()->forEach(
fn($item) =>
print "- $item" . \PHP_EOL
);
print 'Items in collection: ' . $foo->count() . \PHP_EOL;