PHP code example of rdisme / files

1. Go to this page and download the library: Download rdisme/files library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

rdisme / files example snippets


use Rdisme\Files\Dir;


$config = array(
    // 待读取目录地址,必传
    'dir_path' => dirname(__DIR__),

    // 指定读取文件数量,不传默认读取所有文件
    'files_num' => 3,

    // 指定过滤的文件名,不传默认过滤 array('.', '..')
    'filter' => array()
);

$ds = new Dir($config);

$ds->readDir(function ($filepath) {
    var_dump($filepath);
    echo '<hr>';
});

use Rdisme\Files\File;

File::readLine($filepath, function ($line) {
    var_dump($line);
    echo '<hr>';
});