How can pathinfo() function be utilized in PHP to extract file extension?
To extract the file extension using the pathinfo() function in PHP, you can pass the PATHINFO_EXTENSION constant as the second parameter to the function. This will return the extension of the file specified in the path.
// Example code to extract file extension using pathinfo() function
$file = 'example.txt';
$extension = pathinfo($file, PATHINFO_EXTENSION);
echo $extension; // Output: txt
Related questions
-
JOIN PHP MySQL
-
charting libraries PHP conflicts
-
PHP HTML output MySQL database