ArrayObject::offsetGet

(PHP 5 >= 5.0.0, PHP 7)
Returns the value at the specified index
public mixed ArrayObject::offsetGet ( mixed $index )
Parameters:
index

The index with the value.

Returns:

The value at the specified index or NULL.

Exception:

Produces an E_NOTICE error message when the specified index does not exist.

Examples:
ArrayObject::offsetGet() example
<?php
$arrayobj = new ArrayObject(array('zero', 7, 'example'=>'e.g.'));
var_dump($arrayobj->offsetGet(1));
var_dump($arrayobj->offsetGet('example'));
var_dump($arrayobj->offsetExists('notfound'));
?>

The above example will output:

int(7)
string(4) "e.g."
bool(false)
doc_php
2016-02-24 16:20:24
Comments
Leave a Comment

Please login to continue.