有路径如下:upload/2016-01-10/aaaa.pdf
使用pathinfo方法可以获得路径、文件名、扩展名:
$url1 = 'upload/2016-01-01/aaaa.pdf'; $path = pathinfo($url1, PATHINFO_DIRNAME );// upload/2016-01-01 $filename = pathinfo($url1, PATHINFO_BASENAME );// aaa.tpdf $exten = pathinfo($url1, PATHINFO_EXTENSION);// pdf