In what scenarios would it be more appropriate to use pathinfo over strrchr for extracting file extensions in PHP?
When extracting file extensions in PHP, it may be more appropriate to use pathinfo over strrchr in scenarios where you need to extract additional information about the file, such as the filename or directory name. pathinfo provides an associative array containing information about the file path, including the filename, dirname, basename, and extension. This can be useful when you need more than just the file extension.
$file_path = "/path/to/file/example.txt";
$file_info = pathinfo($file_path);
$file_extension = $file_info['extension'];
echo $file_extension;