ArrayObject::getFlags
Sets the flags that change the behavior of the ArrayObject.
<?php
void public ArrayObject::getFlags ( void )
?>
ATTENTION
This function gets the behavior flags of the ArrayObject. The ArrayObject::setFlags method provides a list of the available flags.
ArrayObject::STD_PROP_LIST
Properties of the object have their normal functionality when accessed as list.
ArrayObject::ARRAY_AS_PROPS
Entries can be accessed as properties.
EXERCISE
<?php
$Dwarfs = [ 1 => 'Bashful', 2 => 'Doc',
3 => 'Grumpy', 4 => 'Happy',
5 => 'Sneezy', 6 => 'Sleepy', 7 => 'Dopey'];
$dwArrayObject = new ArrayObject($Dwarfs);
$dwcopy = $dwArrayObject->getArrayCopy();
foreach($dwcopy as $dw => $dwc)
{
var_dump($dw, $dwc);
echo '<br>';
}
$flags = $dwArrayObject->getFlags();
echo '<br>The current flag:<br>';
var_dump($flags);
$dwArrayObject->setFlags(ArrayObject::ARRAY_AS_PROPS);
$flags = $dwArrayObject->getFlags();
echo '<br><br>The new flag:<br>';
var_dump($flags);
?>
RESULT
int(1) string(7) "Bashful"
int(2) string(3) "Doc"
int(3) string(6) "Grumpy"
int(4) string(5) "Happy"
int(5) string(6) "Sneezy"
int(6) string(6) "Sleepy"
int(7) string(5) "Dopey"
The current flag:
int(0)
The new flag:
int(2)