PHP add paired values to array, then sort and print
Say I have the name of a file and it's full path in two variables, how can I add them to an array, sort the array by the filename (keeping the two values paired, then loop through the array and print it? This is using a directory iterator. I won't list the whole code as it's quite convuluted, so heres a simplified version of what I'm trying to do:

    <?php
    
    $files = new RecursiveIteratorIterator( new RecursiveDirectoryIterator($pathToIterate));
    
    foreach($files as $file){
    
    $path=str_replace($_SERVER["DOCUMENT_ROOT"],'',$file->getPathname());
    $file_name = basename($path,'.'.$info['extension']);
    
      // Need code to add $file_name and $path to array //
    		
    	};
    } 
    
    
    // Need code to sort array by $file_name //
    
    // Need code to loop through array and print <a href="$path">$file_name</a> //
    
    
    }
    ?>
PHP add paired values to array, then sort and print
===

Say I have the name of a file and it's full path in two variables, how can I add them to an array, sort the array by the filename (keeping the two values paired, then loop through the array and print it? This is using a directory iterator. I won't list the whole code as it's quite convuluted, so heres a simplified version of what I'm trying to do:

    <?php
    
    $files = new RecursiveIteratorIterator( new RecursiveDirectoryIterator($pathToIterate));
    
    foreach($files as $file){
    
    $path=str_replace($_SERVER["DOCUMENT_ROOT"],'',$file->getPathname());
    $file_name = basename($path,'.'.$info['extension']);
    
      // Need code to add $file_name and $path to array //
    		
    	};
    } 
    
    
    // Need code to sort array by $file_name //
    
    // Need code to loop through array and print <a href="$path">$file_name</a> //
    
    
    }
    ?>