How can you separate the file name from the file type in PHP?

To separate the file name from the file type in PHP, you can use the pathinfo() function to extract the file extension and then use basename() function to get the file name without the extension. This can be useful when you need to manipulate or display the file name and type separately in your application.

$file = "example.txt";
$filename = pathinfo($file, PATHINFO_FILENAME);
$filetype = pathinfo($file, PATHINFO_EXTENSION);

echo "File Name: " . $filename . "<br>";
echo "File Type: " . $filetype;