PHP Basics

ArrayAccessTrait

A generic implementation of the ArrayAccess interface.

Internally it accesses the protected $_data array.

Tags
author

Sebastian Meyer sebastian.meyer@opencultureconsulting.com

template

TValue of mixed

Table of Contents

Methods

offsetExists()  : bool
Check if the specified offset exists.
offsetGet()  : TValue|null
Retrieve data at the specified offset.
offsetSet()  : void
Assign a value to the specified offset.
offsetUnset()  : void
Unset the specified offset.

Methods

offsetExists()

Check if the specified offset exists.

public offsetExists(string|int $offset) : bool
APIYes
Parameters
$offset : string|int

The offset to check for

Return values
bool

Whether the offset exists

offsetGet()

Retrieve data at the specified offset.

public offsetGet(string|int $offset) : TValue|null
APIYes
Parameters
$offset : string|int

The offset to retrieve

Return values
TValue|null

The value at the offset or NULL if invalid

offsetSet()

Assign a value to the specified offset.

public offsetSet(string|int|null $offset, TValue $value) : void
APIYes
Parameters
$offset : string|int|null

The offset to assign to or NULL to append

$value : TValue

The value to set

offsetUnset()

Unset the specified offset.

public offsetUnset(string|int $offset) : void
APIYes
Parameters
$offset : string|int

The offset to unset


        
On this page

Search results