####Why numbering should start at one
####Example
$arr = new SenseArr();
$arr[] = 'foo';
print_r($arr);Result
SenseArr Object
(
[arr] => Array
(
[1] => foo
)
)
####Why numbering should start at one
####Example
$arr = new SenseArr();
$arr[] = 'foo';
print_r($arr);Result
SenseArr Object
(
[arr] => Array
(
[1] => foo
)
)
| class SenseArr implements ArrayAccess | |
| { | |
| public function offsetSet($key, $value) | |
| { | |
| if (count($this->arr) == 0 && $key == null) { | |
| $this->arr[1] = $value; | |
| return; | |
| } | |
| $this->arr[$key] = $value; | |
| } | |
| public function offsetGet($key) | |
| { | |
| return $this->offsetExists($key) ? $this->arr[$key] : null; | |
| } | |
| public function offsetExists($key) | |
| { | |
| return isset($this->arr[$key]); | |
| } | |
| public function offsetUnset($key) | |
| { | |
| unset($this->arr[$key]); | |
| } | |
| } |