How can the basename function or pathinfo with PATHINFO_FILENAME be used to remove directory names from file paths in PHP?

To remove directory names from file paths in PHP, you can use the `basename` function or `pathinfo` with the `PATHINFO_FILENAME` flag. These functions will extract the filename from the full path, effectively removing any directory names.

// Using basename function
$fullPath = "/path/to/directory/file.txt";
$filename = basename($fullPath);
echo $filename; // Outputs: file.txt

// Using pathinfo with PATHINFO_FILENAME
$fullPath = "/path/to/directory/file.txt";
$filename = pathinfo($fullPath, PATHINFO_FILENAME);
echo $filename; // Outputs: file