PHP code example of affinity4 / collection
1. Go to this page and download the library: Download affinity4/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/ */
affinity4 / collection example snippets
use Affinity4\Collection;
$Collection = new Collection([
0 => 'one',
1 => 'two',
2 => 'three'
]);
$Collection->key(); // 0
$Collection->current(); // one
$Collection->valid(); // true
$Collection->next();
$Collection->key(); // 1
$Collection->valid(); // true
$Collection->current(); // two
$Collection->next();
$Collection->key(); // 2
$Collection->valid(); // true
$Collection->current(); // three
$Collection->next();
$Collection->key(); // 3
$Collection->valid(); // false
$Collection->prev();
$Collection->key(); // 2
$Collection->valid(); // true
$Collection->current(); // three
$Collection->rewind();
$Collection->key(); // 0
$Collection->valid(); // true
$Collection->current(); // one
use Affinity4\Collection;
$Collection = new Collection([
0 => 'one',
1 => 'two',
2 => 'three',
'one' => 1,
'two' => 2,
'three' => 3
]);
$Collection[0]; // one
$Collection[1]; // two
$Collection[2]; // three
$Collection['one']; // 1
$Collection['two']; // 2
$Collection['three']; // 3