The method of one line of code in php to get the file suffix name requires a combination of many functions. Ours is a bit like the function in asp. Let’s take a look below.
Example:
The code is as follows | |||||
$rs = strtolower(trim(substr(strrchr($filename, ”.“), 1))); |
Detailed explanation:
The strrchr() function finds the last occurrence of a string in another string and returns all characters from that position to the end of the string;
The substr() function returns a part of the string, 1 means reading from the first subscript of the string. Until the end;
The strtolower() function converts a string to lowercase.
代码如下 | |
//方法一: |
The code is as follows | |
//Method 1:
//Method 3
function extend_3($file_name)<🎜>
{<🎜>
$extend =explode("." , $file_name);<🎜>
$va=count($extend)-1;<🎜>
return $extend[$va];<🎜>
}<🎜>
?>
|
return $extend;
}