elementAt()
elementAt(mixed $key) : mixed
Returns the value at a specified key in a sequence.
Syntax: elementAt (key)
Returns the value at a specified key in a sequence.
If the type of source iterator implements \ArrayAccess, that implementation is used to obtain the value at the specified key. Otherwise, this method obtains the specified value.
This method throws an exception if key is not found. To instead return a default value when the specified key is not found, use the \elementAtOrDefault method.
Parameters
mixed | $key | The key of the value to retrieve. |
Throws
- \UnexpectedValueException
If sequence does not contain value with specified key.
Returns
mixed —The value at the key in the source sequence.