ftp_nlist

(PHP 3 >= 3.0.13, PHP 4, PHP 5)

ftp_nlist -- 返回给定目录的文件列表

说明

array ftp_nlist ( resource ftp_stream, string directory )

如果成功则返回给定目录下的文件名组成的数组,否则返回 FALSE

例子 1. ftp_nlist() 例子

<?php
// set up basic connection
$conn_id = ftp_connect ( $ftp_server );
$login_result = ftp_login ( $conn_id , $ftp_user_name , $ftp_user_pass );

// check connection
if ((! $conn_id ) || (! $login_result )) {
    die(
"FTP connection has failed !" );
}

// get contents of the root directory
$contents = ftp_nlist ( $conn_id , "/" );

// print each entry
foreach ( $contents as $entry ) {
    echo
$entry , "<br />\n" ;
}
?>

参见 ftp_rawlist()