PHP code example of affinity4 / file
1. Go to this page and download the library: Download affinity4/file 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/ */
affinity4 / file example snippets
root
|-- files
| |-- config.yml
| |-- config.php
| |-- 00
| | |-- test00-01.php
| | |-- test00-01.yml
| | |-- test00-02.php
| | |-- test00-02.yml
| | |-- 01
| | | | |-- test01-01.php
| | | | |-- test01-01.yml
| | | | |-- test01-02.php
| | | | |-- test01-02.yml
| | | | |-- test01-03.php
| | | | |-- test01-03.yml
| | | | |-- 02
| | | | | |-- YOU-ARE-HERE
| | | | | |-- test02-01.html
| | | | | |-- test02-01.css
| | | | | |-- test02-01.json
| | | | | |-- test02-02.json
$file = new Affinity4\File\File;
$results = $file->find('/^test[\d]{2}-[\d]{2}.json$/')->in(__DIR__)->get();
$results[0]->getPathname(); // root/files/00/01/02/test02-01.json
$results[1]->getPathname(); // root/files/00/01/02/test02-02.json
$file = new Affinity4\File\File;
$results = $file->find('/^test00-[\d]{2}.php$/')->in(__DIR__)->parent()->get();
$results[0]->getPathname(); // root/files/00/test00-01.php
$results[1]->getPathname(); // root/files/00/test00-02.php
$file = new Affinity4\File\File;
$result = $file->find('config.yml')->in(__DIR__)->parents()->get();
$result->getPathname(); // root/files/config.yml
$file = new Affinity4\File\File;
$result = $file->find('/^test[\d]{2}-[\d]{2}.php$/')->in(__DIR__)->parents()->get(1);
return $result->getPathname() // root/files/00/01/test01-01.php;
$file = new Affinity4\File\File;
$results = $file->find('/^test[\d]{2}-[\d]{2}.php$/')->in(__DIR__)->parents()->get(2);
$results[0]->getPathname(); // root/files/00/01/test01-01.php;
$results[1]->getPathname(); // root/files/00/01/test01-02.php;