ArrayObject::offsetUnset


Unsets the value at the specified index.



<?php

void 
public ArrayObject::offsetUnset mix $index )


where,

$index The index to be unset

?>

$index


The index being unset.



  1 EXERCISE   

<?php

$Dwarfs 
= [ => 'Bashful'=> 'Doc'
                   
=> 'Grumpy'=> 'Happy'
                   
=> 'Sneezy'=> 'Sleepy'=> 'Dopey'
                   
=> 'Snow White'];

$dwArrayObject = new ArrayObject($Dwarfs);

print_r($dwArrayObject);

for(
$j 1$j <= 7$j++)
    
$dwArrayObject->offsetUnset($j);

echo 
'<br><br>';

print_r($dwArrayObject);

?>

 RESULT   

ArrayObject Object ( [storage:ArrayObject:private] => Array ( [1] => Bashful [2] => Doc [3] => Grumpy [4] => Happy [5] => Sneezy [6] => Sleepy [7] => Dopey [8] => Snow White ) )

ArrayObject Object ( [storage:ArrayObject:private] => Array ( [8] => Snow White ) )