IteratorAggregate::getIterator
ArrayAccess::offsetExists
Predefined Interfaces
PHP Manual

# The ArrayAccess interface

## Wstęp

Interface to provide accessing objects as arrays.

## Zestawienie interfejsu

ArrayAccess
ArrayAccess {
/* Metody */
abstract public boolean offsetExists ( mixed `$offset` )
abstract public mixed offsetGet ( mixed `$offset` )
abstract public void offsetSet ( mixed `$offset` , mixed `$value` )
abstract public void offsetUnset ( mixed `$offset` )
}

Przykład #1 Basic usage

`<?php
class obj implements arrayaccess {
private $container = array();
public function __construct() {
$this->container = array(
"one" => 1,
"two" => 2,
"three" => 3,
);
}
public function offsetSet($offset, $value) {
$this->container[$offset] = $value;
}
public function offsetExists($offset) {
return isset($this->container[$offset]);
}
public function offsetUnset($offset) {
unset($this->container[$offset]);
}
public function offsetGet($offset) {
return isset($this->container[$offset]) ? $this->container[$offset] : null;
}
}
$obj = new obj;
var_dump(isset($obj["two"]));
var_dump($obj["two"]);
unset($obj["two"]);
var_dump(isset($obj["two"]));
$obj["two"] = "A value";
var_dump($obj["two"]);
?>`

Powyższy przykład wyświetli coś podobnego do:

    bool(true)
    int(2)
    bool(false)
    string(7) "A value"

## Spis treści

- ArrayAccess::offsetExists — Whether a offset exists
- ArrayAccess::offsetGet — Offset to retrieve
- ArrayAccess::offsetSet — Offset to set
- ArrayAccess::offsetUnset — Offset to unset

IteratorAggregate::getIterator
ArrayAccess::offsetExists
Predefined Interfaces
PHP Manual