What are potential pitfalls when using explode() function to extract file extensions in PHP?

When using the explode() function to extract file extensions in PHP, a potential pitfall is that it may not work correctly if the file name contains multiple periods. To solve this issue, you can use the pathinfo() function instead, which is specifically designed for extracting file extensions.

$file = "example.file.pdf";
$extension = pathinfo($file, PATHINFO_EXTENSION);
echo $extension; // Output: pdf