du248227 2015-03-09 08:20
浏览 70
已采纳

php如何缩短url - glob函数

I use a glob function to list a folder items, the code below give me text like this "flash/movies", but I would like to trim the url to display only "movies". Can you help me what should I do ?

$dir = glob("flash/*");        
usort($dir, function($a, $b){
return filemtime($a) < filemtime($b);
    });
  foreach ($dir as $plk) { 
     echo '<h4>' . $plk . '</h4>';
  }
  • 写回答

1条回答 默认 最新

  • dtbc37573 2015-03-09 08:25
    关注

    You can use the basename() function. This returns the "trailing path component", which is the directory name that you are looking for.

    For example:

    echo '<h4>' . basename($plk) . '</h4>';
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?