//方法一:
function extend_1($file_name)
{
??? $retval="";
? $pt=strrpos($file_name, ".");
? if ($pt) $retval=substr($file_name, $pt+1, strlen($file_name) - $pt);
?戻り値 ($retval);
}
//方法二
function extend_2($file_name)
{
??? $extend = パス情報($file_name);
??? $extend = strto lower($extend["extension"]);
??? $extend を返します。
}
//方法三
function extend_3($file_name)
{
??? $extend =explode("." , $file_name);
??? return $extend[1];
}
$file = "c:test.testhaha.haha.txt";
echo extend_1($file);
echo "n
n";
echo extend_2($file) ;
echo "n
n";
echo extend_3($file);
?>
返還結果:
txt
txt
testhaha
============== ===============================================
$ file = "a.b.c.jpeg";
$ext = strrchr($file, ".");
print $ext;