1. Go to this page and download the library: Download mediagone/types-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/ */
use App\Foo;
use Mediagone\Types\Collections\ClassCollection;
class FooCollection extends ClassCollection
{
protected static function classFqcn() : string
{
return Foo::class;
}
}
/*
* @extends ClassCollection<Foo>
*/
class FooCollection extends ClassCollection
{
$collection = StringCollection::fromArray(['item1', 'item2']);
// Add a value at the end of the collection
$collection->append('item3');
// Add a value at the start of the collection
$collection->prepend('item0');
var_dump($collection->toArray());
// Outputs:
// array(4) {
// [0] => string(5) "item0"
// [1] => string(5) "item1"
// [2] => string(5) "item2"
// [3] => string(5) "item3"
// }
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.