ArrayObject::offsetExists
PHP function
Edit on GitHub ✎
(PHP 5, PHP 7, PHP 8)
Returns whether the requested index exists
Description
ArrayObject::offsetExists(mixed $key): bool
Parameters
keyThe index being checked.
Return Values
true if the requested index exists, otherwise false
Examples
ArrayObject::offsetExists example
php
<?php
$arrayobj = new ArrayObject(array('zero', 'one', 'example'=>'e.g.'));
var_dump($arrayobj->offsetExists(1));
var_dump($arrayobj->offsetExists('example'));
var_dump($arrayobj->offsetExists('notfound'));
?>The above example will output:
output
bool(true)
bool(true)
bool(false)