PHP code example of codeinc / array-access
1. Go to this page and download the library: Download codeinc/array-access 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/ */
codeinc / array-access example snippets
use CodeInc\ArrayAccess\ArrayAccessTrait;
use CodeInc\ArrayAccess\AbstractArrayAccess;
use CodeInc\ArrayAccess\ArrayAccess;
/*
* As a trait
*/
class MyArrayAccesssibleClass1 implements \ArrayAccess {
use ArrayAccessTrait;
protected function getAccessibleArray():array {
// returns the accessible array
}
}
/*
* As a parent class
*/
class MyArrayAccesssibleClass2 extends AbstractArrayAccess {
protected function getAccessibleArray():array {
// returns the accessible array
}
}
/*
* As a autonomous object
*/
$arrayAccessible = new ArrayAccess([1 => "One", 2 => "Two", 3 => "Three"]);
echo $arrayAccessible[2]; // echoes "Two"
bash
composer