What are some best practices for sorting and manipulating arrays of file names in PHP?

When working with arrays of file names in PHP, it is important to be able to sort and manipulate them efficiently. One common way to sort file names is alphabetically, either in ascending or descending order. Additionally, you may need to filter out certain file names based on specific criteria or perform operations on the file names themselves.

// Example: Sorting an array of file names alphabetically
$files = ['file3.txt', 'file1.txt', 'file2.txt'];

// Sort the array in ascending order
asort($files);

// Print the sorted array
foreach ($files as $file) {
    echo $file . "\n";
}