php8.5
Home/ Manual/ reflection / reflectionreference/ ReflectionReference::fromArrayElement

ReflectionReference::fromArrayElement

PHP function Edit on GitHub ✎

(PHP 7 >= 7.4.0, PHP 8)

Create a ReflectionReference from an array element

Description

ReflectionReference::fromArrayElement(array $array, int|string $key): ReflectionReference|null

Creates a ReflectionReference from an array element.

Parameters

array

The Array which contains the potential reference.

key

The key; either an Integer or a String.

Return Values

Returns a ReflectionReference instance if $array[$key] is a reference, or null otherwise.

Errors/Exceptions

If array is not an Array, or key is not an Integer or String, a TypeError is thrown. If $array[$key] does not exist, a ReflectionException is thrown.

Source: reference/reflection/reflectionreference/fromarrayelement.xml · from the official PHP manual (php/doc-en)