PHP code example of steein / collections
1. Go to this page and download the library: Download steein/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/ */
steein / collections example snippets
use Steein\Common\Collections\Collection;
//Generated default array
$array = [
'name' => 'Shamsudin',
'project' => 'Steein',
'text' => 'default text',
'Cars' => [
'car_audi' => 'Audi',
'car_bwm' => 'Bmw'
]
];
//Default
$collection = new Collection($array);
//Or Static implementation
$collection = Collection::instance($array);
$collection->new_array = 'value';
$collection->toArray()
$collection->toJson();
$collection->toXml();
$collection->set('key', 'value');
$collection->get('key');
$collection->slice(1);
$collection->nth(2);
$new_collection = Collection::instance([0 => ['a'], 1 => ['b'], 2 => ['c']]);
$new_collection->union([3 => ['b'], 2 => ['c']]);
$new_collection = Collection::instance(['firstname','lastname','age']);
$new_collection->combine(['Shamsudin','Serderov', 22]);
$new_collection = Collection::instance(['id_goods' => 100,'price' => 10000, 'instock' => 0]);
$new_collection->merge(['price' => 9550, 'count' => 1]);
$collection->isEmpty();
$collection->isNotEmpty();
$collection->has('project');
$collection->forget('name');
$new_collection = Collection::instance(['test', 'test1']);
$new_collection->archive([50, 22]);
$collection->clear();
$collection->count()
$flip = $collection->flip();
$flip->all();
$collection->values();
$collection->keys();
$collection->indexOf('Shamsudin');
$collection->all();