What are the potential pitfalls of using explode() to extract file extensions in PHP?

Using explode() to extract file extensions in PHP can be problematic because it relies on assuming the position of the period in the file name, which may not always be accurate. A more reliable approach is to use the pathinfo() function, which returns an associative array containing information about a file path.

$filename = "example.jpg";
$extension = pathinfo($filename, PATHINFO_EXTENSION);
echo $extension;