<?php
bool public ArrayObject::offsetExists ( mix $index )
where,
$index = The index to be checked
?>
<?php
$Dwarfs = [ 1 => 'Bashful', 2 => 'Doc',
3 => 'Grumpy', 4 => 'Happy',
5 => 'Sneezy', 6 => 'Sleepy', 7 => 'Dopey'];
$dwArrayObject = new ArrayObject($Dwarfs);
for($i = 0; $i <= 8; $i++)
if($dwArrayObject->offsetExists($i) == TRUE)
{
echo 'The index ' . $i . ' exists<br>';
}
else
{
echo 'The index ' . $i . ' does not exists<br>';
}
?>