php从文件名中删除字符


php strip characteres from file name

我有一个名为products_5245_20130709_101812_2.xmlGkcW7B 的文件

我想将其重命名为products_5245_20130709_101812_2.xml,删除xml后的所有字符。

如何用preg_replace或任何其他方法做到这一点???

提前谢谢?

有什么问题

$filename = preg_replace('/'.xml.+$/','.xml',$filename);