<?php
ArrayIterator public ArrayObject::getIterator ( void )
?>
<?php
$Dwarfs = [ 1 => 'Bashful', 2 => 'Doc',
3 => 'Grumpy', 4 => 'Happy',
5 => 'Sneezy', 6 => 'Sleepy', 7 => 'Dopey'];
$dwArrayObject = new ArrayObject($Dwarfs);
$iterator = $dwArrayObject->getIterator();
while($iterator->valid())
{
echo '[ ' . $iterator->key() . ' ] => ' . $iterator->current() . '<br><br>';
$iterator->next();
}
?>
<?php
class Test02 {
public string $var_a = 'Alea Jacta Est';
private string $var_b = 'Maxima debetur puero reverentia';
protected string $var_c = 'Ad augusta per angusta';
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
This type declarations is supported,
only, as of PHP 7.4.0
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
$obj02 = new Test02;
print_r($obj02);
echo '<br><br>';
$arrayobj = new ArrayObject($obj02);
$iterator = $arrayobj->getIterator();
while($iterator->valid())
{
echo '[ ' . $iterator->key() . ' ] => ' . $iterator->current() . '<br><br>';
$iterator->next();
}
?>
<?php
class Test03 {
public string $var_a = 'Alea Jacta Est';
public string $var_b = 'Maxima debetur puero reverentia';
public string $var_c = 'Ad augusta per angusta';
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
This type declarations is supported,
only, as of PHP 7.4.0
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
$obj03 = new Test03;
print_r($obj03);
echo '<br><br>';
$arrayobj = new ArrayObject($obj03);
$iterator = $arrayobj->getIterator();
while($iterator->valid())
{
echo '[ ' . $iterator->key() . ' ] => ' . $iterator->current() . '<br><br>';
$iterator->next();
}
?>