PHP code example of ialopezg / collections
1. Go to this page and download the library: Download ialopezg/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/ */
ialopezg / collections example snippets
use ialopezg\Libraries\Collection;
// class derived from Collection class
class ItemCollection extends Collection { }
$collection = new ItemCollection([]);
// get the value, if not found return default value
echo $collection->get('item_name', 'initial value');
// changing item_name's value
$collection->set('item_name', 'item value');
// print current value
if ($collection->has('item_name')) {
echo $collection->get('item_name');
}
// remove item_name property
$collection->remove('item_name');
echo $collection->count();
echo $collection->itemName;