DirectoryIterator::key

(PHP 5)

DirectoryIterator::keyReturn the key for the current DirectoryIterator item

Опис

public string DirectoryIterator::key ( void )

Get the key for the current DirectoryIterator item.

Параметри

В цієї функції немає параметрів.

Значення, що повертаються

The key for the current DirectoryIterator item.

Приклади

Приклад #1 A DirectoryIterator::key() example

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

Наведений вище приклад виведе щось подібне до:

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

Прогляньте Також

add a note add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top