1. Go to this page and download the library: Download gmi/toolkit-sorter 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/ */
gmi / toolkit-sorter example snippets
use Gmi\Toolkit\Sorter\NaturalFileSorter;
$files = ['file1.pdf', 'file2.pdf'];
$fileInfos = [];
foreach ($files as $file) {
$fileInfos[] = new SplFileInfo($file);
}
$sorter = new NaturalFileSorter();
$sorter->sort($fileInfos);
use Gmi\Toolkit\Sorter\GroupSorter;
use Gmi\Toolkit\Sorter\ExtensionFileSorter;
use Gmi\Toolkit\Sorter\SizeFileSorter;
$files = ['file1.pdf', 'file2.pdf', 'file3.pdf', 'file1.jpg', 'file4.pdf', 'file2.jpg'];
$fileInfos = [];
foreach ($files as $file) {
$fileInfos[] = new SplFileInfo($file);
}
$sorter = new GroupSorter([new ExtensionFileSorter(), new SizeFileSorter()]);
$sorter->sort($fileInfos);
use Symfony\Component\Finder\Finder;
use Gmi\Toolkit\Sorter\SizeFileSorter;
$finder = new Finder();
$finder->files()->name('/\.jpg$/i')->in($folder);
$files = iterator_to_array($finder);
$sorter = new SizeFileSorter();
$sorter->sort($files);
use Symfony\Component\Finder\Finder;
use Gmi\Toolkit\Sorter\ModificationDateFileSorter;
$finder = new Finder();
$finder->files()->name('/\.jpg$/i')->in($folder);
$sorter = new ModificationDateFileSorter();
$finder->sort($sorter->getClosure());
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.