PHP Basics

ArrayAccessTrait

A generic implementation of the ArrayAccess interface.

Tags
author

Sebastian Meyer sebastian.meyer@opencultureconsulting.com

template

TKey of int|string

template

TValue of mixed

template

TData of array<TKey, TValue>

Table of Contents

Properties

$data  : TData
Holds the array-accessible data.

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.

Properties

Methods

offsetExists()

Check if the specified offset exists.

public offsetExists(TKey $offset) : bool
APIYes
Parameters
$offset : TKey

The offset to check for

Return values
bool

Whether the offset exists

offsetGet()

Retrieve data at the specified offset.

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

The offset to retrieve at

Return values
TValue|null

The value at the offset or NULL

offsetSet()

Assign a value to the specified offset.

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

The offset to assign to or NULL to append

$value : TValue

The value to set

offsetUnset()

Unset the specified offset.

public offsetUnset(TKey $offset) : void
APIYes
Parameters
$offset : TKey

The offset to unset


        
On this page

Search results