我正在爆炸"." 获取文件格式和名称:
list($txt, $ext) = explode(".", $name);
Run Code Online (Sandbox Code Playgroud)
问题是某些文件的名称带有点.
我如何在最后一次探索"." 所以我得到$name=pic.n2和$ext=jpg来自:pic.n2.jpg?
DCo*_*der 17
使用pathinfo:
$pi = pathinfo($name);
$txt = $pi['filename'];
$ext = $pi['extension'];
Run Code Online (Sandbox Code Playgroud)
dec*_*eze 12
$name = pathinfo($file, PATHINFO_FILENAME);
$ext = pathinfo($file, PATHINFO_EXTENSION);
Run Code Online (Sandbox Code Playgroud)
用这个
$array = explode(".", $name);
end($array); // move the internal pointer to the end of the array
$filetype = current($array);
Run Code Online (Sandbox Code Playgroud)
谢谢