Home > Article > Backend Development > Very good directory navigation file php code_PHP tutorial
Although this code is short, it is very practical. It can easily create a hyperlink to the file with the specified suffix name in the directory you specify, and it can be set so that the homepage of the specified directory will not be navigated.
function navbar(){
$files = dir("."); //Specify directory
$pipe = " | "; //Pipe character
//Search all files in the directory through the following loop
while ($current = $files->read()) {
//ignor all files not of htm type.
if (strpos($ current, "php")!= FALSE) //Files with the suffix PHP will be navigated
//Ignore themselves (such as index.html)
{ if (strpos($current, "ndex") == FALSE)
{
print "print $current;
print ">";
print $current;
print "";
print $pipe;
} ;
};
};
};
navbar() //Call function
?>