PHP Doku:: Return the key for the current DirectoryIterator item - directoryiterator.key.html

Verlauf / Chronik / History: (1) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzSonstige GrunderweiterungenStandard PHP Library (SPL)IteratorenThe DirectoryIterator classDirectoryIterator::key

Ein Service von Reinhard Neidl - Webprogrammierung.

The DirectoryIterator class

<<DirectoryIterator::isWritable

DirectoryIterator::next>>

DirectoryIterator::key

(PHP 5)

DirectoryIterator::keyReturn the key for the current DirectoryIterator item

Beschreibung

public string DirectoryIterator::key ( void )

Get the key for the current DirectoryIterator item.

Parameter-Liste

Diese Funktion hat keine Parameter.

Rückgabewerte

The key for the current DirectoryIterator item.

Beispiele

Beispiel #1 A DirectoryIterator::key() example

<?php
$dir 
= new DirectoryIterator(dirname(__FILE__));
foreach (
$dir as $fileinfo) {
    if (!
$fileinfo->isDot()) {
        echo 
$fileinfo->key() . " => " $fileinfo->getFilename() . "\n";
    }
}
?>

Das oben gezeigte Beispiel erzeugt eine ähnliche Ausgabe wie:

0 => apple.jpg
1 => banana.jpg
2 => index.php
3 => pear.jpg

Siehe auch


Keine BenutzerBeiträge.
- Beiträge aktualisieren...



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)