AppendIterator::key
Gets the current key
&reftitle.description;
public scalarAppendIterator::key
Get the current key.
&reftitle.parameters;
&no.function.parameters;
&reftitle.returnvalues;
The current key if it is valid or &null; otherwise.
&reftitle.examples;
AppendIterator::key basic example
'aardwolf', 'b' => 'bear', 'c' => 'capybara'));
$array_b = new ArrayIterator(array('apple', 'orange', 'lemon'));
$iterator = new AppendIterator;
$iterator->append($array_a);
$iterator->append($array_b);
// Manual iteration
$iterator->rewind();
while ($iterator->valid()) {
echo $iterator->key() . ' ' . $iterator->current() . PHP_EOL;
$iterator->next();
}
echo PHP_EOL;
// With foreach
foreach ($iterator as $key => $current) {
echo $key . ' ' . $current . PHP_EOL;
}
?>
]]>
&example.outputs;
&reftitle.seealso;
Iterator::key
AppendIterator::current
AppendIterator::valid
AppendIterator::next
AppendIterator::rewind