ArrayObject::offsetExists


Returns whether the requested index exists.



<?php

bool 
public ArrayObject::offsetExists mix $index )


where,

$index The index to be checked

?>

$index


The index being checked.



  1 EXERCISE   

<?php

$Dwarfs 
= [ => 'Bashful'=> 'Doc'
                   
=> 'Grumpy'=> 'Happy'
                   
=> 'Sneezy'=> 'Sleepy'=> '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>';
}

?>

 RESULT   

The index 0 does not exists
The index 1 exist
The index 2 exists
The index 3 exists
The index 4 exists
The index 5 exists
The index 6 exists
The index 7 exists

The index 8 does not exists