Basename returning filename x 100
Posted: Mon May 15, 2006 2:26 pm
I have included the basename() function into my script:
But the problem is that the results returned are returned like like 1000 times dispending of how many match the query. So it would look something like (if 1 file matches the query)
But times 100. Does anyone know how i could resolve this, thanks in advance!
Code: Select all
<form action="page.php?name=Library&file=search" method="POST"><input size="25" type="text" name="query" value=""> <input type="submit" value="Search"></form>
<?php //...
$term = trim($_POST['query']);
$files = glob($dir."modules/Library/files/*");
foreach( $files as $key => $value ){
if(preg_match("#".$term."#i", $value))
$file = basename($value); // $file is set to "index.php"
echo "<a href=\"page.php?name=Library&file=file&page=$value\">$file</a><br>";
} ?>Code: Select all
The file name
The file name
The file name
The file name
The file name
The file name
The file name
The file name
The file name
The file name