首页 > php代码 > php 获取文件名后缀名扩展名

php 获取文件名后缀名扩展名

<?php
/*在php 有这么二个函数 end() 与 current() 前者是读取数组最后一个元素值,后者是读取数组第一个值,
 *那么下面我们来看看我利用end也读取文件111cn.gif文件后缀名gif
*/
$file = 'www.phprm.com.gif';
echo getfix($file);
//得到的值为gif 这种方法最简单也最实例了,好下面我们来看看方法二一种用substr读取扩展名方法
$file = 'aaa.gif';
echo substr($file, strpos($file, '.') + 1);
//方法三 还是用数组
$file = 'phprm.gif';
$d111cn = explode('.', $file);
echo $d111cn[count($d111cn) - 1];
function getfix($l1) {
    return end(explode('.', $l1));
}


本文链接:http://www.phprm.com/code/358ad3dd52a90fd7894a1047adc80208.html

收藏随意^^请保留教程地址.

标签:none

发表留言