What function can be used in PHP to extract the filename from a URL?

To extract the filename from a URL in PHP, you can use the `basename()` function. This function returns the trailing name component of the path, which in this case would be the filename. You can pass the URL as a parameter to the `basename()` function to extract just the filename.

$url = "https://www.example.com/path/to/file.txt";
$filename = basename($url);
echo $filename; // Output: file.txt