1. Go to this page and download the library: Download linkorb/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/ */
linkorb / collection example snippets
$monkeys = new \Collection\TypedArray(Monkey::class);
$monkeys->add(new Monkey('Bubbles')); // OK
$monkeys[] = new Monkey('King Kong'); // OK
$monkeys->add(new Snake('Kaa')); // throws CollectionException
// You can iterate over the collection
foreach ($monkeys as $monkey) {
echo $monkey->getName();
}
$monkeys[] = new Monkey('King Kong');
$monkeys->add(new Monkey('King Kong'));
class Monkey implements \Collection\Identifiable
{
protected $name;
public function __construct($name)
{
$this->name = $name;
}
public function identifier()
{
return $this->name;
}
}
class Zoo
{
protected $monkeys;
public function __construct()
{
$this->monkeys = new Collection\TypedArray(Monkey::class);
}
public function getMonkeys()
{
return $this->monkeys;
}
}
$zoo = new Zoo();
$zoo->getMonkeys()->add(new Monkey('Koko');
foreach ($zoo->getMonkeys() as $monkey() {
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.