Glob() filesearch, question

Posted by Peter on Stack Overflow See other posts from Stack Overflow or by Peter
Published on 2010-05-26T14:18:30Z Indexed on 2010/05/26 14:21 UTC
Read the original article Hit count: 277

Filed under:
|
|
|

Hi, a little question. I have this code, which is works perfect for files, but If am trying search on a directory name, the result is blank. How I can fix that?

<?php
function listdirs($dir,$search)
{
    static $alldirs = array();
    $dirs = glob($dir."*");
        foreach ($dirs as $d){
if(is_file($d)){
$filename = pathinfo($d);
if(eregi($search,$filename['filename'])){   
print  "<a href=http://someurl.com/" . $d .">". $d . "</a><br/>";
}
}else{
listdirs($d."/",$search);
}
}
}
$path = "somedir/";
$search= "test";
listdirs($path,$search);
?>

somedir/test/

result: blank (I want: /somedir/test/)

somedir/test/test.txt

result: OK

I want to search also in the directory names, how I can do that?

© Stack Overflow or respective owner

Related posts about php

Related posts about file