如果你这里的$file是文件名,那么你用explode拆分,看拆分后数组最后一个元素,如果不等于exe或php,就不echo 

解决方案 »

  1.   


    if(substr($file,-3) == "php"){
     echo $file."<br>";
    }
      

  2.   

    $ext = explode('.',$file);
    if($ext[count($ext)-1] == "php"){
     echo $file."<br>";
    }
      

  3.   

    看唠叨老大的精华贴
     http://expert.csdn.net/Expert/topic/2383/2383886.xml?temp=.403866
      

  4.   

    用正刚表达式
    function CheckPHPExE($filename) 
    {
    $img_exts = array("php","exe");
    foreach($img_exts as $this_ext) {
    if (preg_match("/\.$this_ext$/", $filename)) {
    return true;
    }
    }
    return false;
    }这个比较通用,可以用在许多地方比如,判断是不是gif类型的文件时,只要把$img_exts = array("php","exe");改成$img_exts = array("gif");其余类推
      

  5.   

    http://www.csdn.net/Develop/article/26/26041.shtm
    我的文章刚发表,,庆祝,应该对你有用