<code>ArrayAccess</code> arayüzü ArrayAccess
&reftitle.intro; Nesnelere birer dizi olarak erişmeyi sağlayan arayüz.
&reftitle.interfacesynopsis; ArrayAccess &Methods;
&reftitle.examples; Temel kullanım 1, "iki" => 2, "üç" => 3, ]; public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; } else { $this->container[$offset] = $value; } } public function offsetExists($offset): bool { return isset($this->container[$offset]); } ublic function offsetUnset($offset): void { unset($this->container[$offset]); } public function offsetGet($offset): mixed { return isset($this->container[$offset]) ? $this->container[$offset] : null; } } $obj = new Obj; var_dump(isset($obj["iki"])); var_dump($obj["iki"]); unset($obj["iki"]); var_dump(isset($obj["iki"])); $obj["iki"] = "Bir değer"; var_dump($obj["iki"]); $obj[] = 'Ek 1'; $obj[] = 'Ek 2'; $obj[] = 'Ek 3'; print_r($obj); ?> ]]> &example.outputs.similar; Array ( [bir] => 1 [üç] => 3 [iki] => Bir değer [0] => Ek 1 [1] => Ek 2 [2] => Ek 3 ) ) ]]>
&language.predefined.arrayaccess.offsetexists; &language.predefined.arrayaccess.offsetget; &language.predefined.arrayaccess.offsetset; &language.predefined.arrayaccess.offsetunset;