php - Remove dot in get list of files in directory -
how can remove dot before last trailing slash?
example dot output in html table:
name type size last modified http://www.airsahara.in./fares/ text/x-php 662 2014-09-04 http://www.airsahara.in./ text/x-php 1681 2014-09-04 here php code have allows me read directories based on in ignore array. can't figure out how rid of . before trailing slash /.
i need remove dot url can correct.
<? $ignore = array( 'images', 'css', 'includes', 'cgi-bin', 'xml-sitemap.php' ); function getfilelist($dir, $recurse=false) { global $ignore; $retval = array(); // open pointer directory , read list of files $d = @dir($dir) or die("getfilelist: failed opening directory $dir reading"); while ( false !== ( $entry = $d->read() ) ) { // check if dir needs ignored, if so, skip it. if ( in_array( utf8_encode( $entry ), $ignore ) ) continue; // skip hidden files if($entry[0] == ".") continue; if(is_dir("$dir$entry")) { $retval[] = array( "name" => "$dir$entry/", "type" => filetype("$dir$entry"), "size" => 0, "lastmod" => filemtime("$dir$entry") ); if($recurse && is_readable("$dir$entry/")) { $retval = array_merge($retval, getfilelist("$dir$entry/", true)); } } elseif(is_readable("$dir$entry")) { $retval[] = array( "name" => "$dir", "type" => mime_content_type("$dir$entry"), "size" => filesize("$dir$entry"), "lastmod" => filemtime("$dir$entry") ); } } $d->close(); return $retval; } $dirlist = getfilelist("./", true); // output file list in html table format echo "<table border=\"1\">\n"; echo "<thead>\n"; echo "<tr><th>name</th><th>type</th><th>size</th><th>last modified</th></tr>\n"; echo "</thead>\n"; echo "<tbody>\n"; foreach($dirlist $file) { if($file['type'] != 'text/x-php') continue; echo "<tr>\n"; echo "<td>http://www.airsahara.in{$file['name']}</td>\n"; echo "<td>{$file['type']}</td>\n"; echo "<td>{$file['size']}</td>\n"; echo "<td>",date('y-m-d', $file['lastmod']),"</td>\n"; echo "</tr>\n"; } echo "</tbody>\n"; echo "</table>\n\n"; ?>
you perform string replace -
"name" => str_replace('./','/', $dir),
Comments
Post a Comment