DirectoryIterator::key
Return the key for the current DirectoryIterator item
&reftitle.description;
public mixedDirectoryIterator::key
Get the key for the current DirectoryIterator item.
&reftitle.parameters;
&no.function.parameters;
&reftitle.returnvalues;
The key for the current DirectoryIterator item as an &integer;.
&reftitle.changelog;
&Version;
&Description;
8.1.0
When the iterator is uninitialized, an Error is
thrown now. Previously, the method returned &false;.
&reftitle.examples;
A DirectoryIterator::key example
isDot()) {
echo $fileinfo->key() . " => " . $fileinfo->getFilename() . "\n";
}
}
?>
]]>
&example.outputs.similar;
apple.jpg
1 => banana.jpg
2 => index.php
3 => pear.jpg
]]>
&reftitle.seealso;
DirectoryIterator::current
DirectoryIterator::next
DirectoryIterator::rewind
DirectoryIterator::valid
Iterator::key