Q:

Write a PHP program to get the extension of a file

0

Write a PHP program to get the extension of a file

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

<?php
function file_extension($str1){
    $str1=implode("",explode("\",$str1));
    $str1=explode(".",$str1);
    $str1=strtolower(end($str1));
     return $str1;
}

$file='example.txt';
echo "\n".file_extension($file)."\n";
?>

Sample Output:

txt

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now