在php中区分目录和文件

I'm new with php. Currently I'm trying to build my own site mapping php project. My test directory is in own localhost that has some other projects, some random files and many many directory. My directory view in default of wamp and is like apache 2.4.9 directory listing.

I am using file_get_contents($url) to browse the directory and using regex to get all the href of tag then browsing those again.

My question is how can I distinguish between directory or file? I don't want to send file_get_contents request to any kind of file but only to directory. But first I need to know which href is a file and which is not for that purpose. Is there any built in php function to do that? Or any idea about how can I do that?

Go ahead and use:

bool is_dir ( string $filename )
// or:
bool is_file ( string $filename )

Source: PHP Documentation is_dir, is_file.

I've found the answer to my question or a way around it. I wanted to know whether a remote/local link is a file or a directory. If it is local(the directory/domain the php file is in) it can be found out by is_dir and is_file functions. If its not on local then there are some problems detecting if its a file or not. So I've found a way around it, first I try to determine the file's size, if I can resolve the file size then its a file if not then its a directory. Got the idea from this
https://gist.github.com/eyecatchup/f26300ffd7e50a92bc4d

function isItAFile($url)
{
    $ch = curl_init($url);
    curl_setopt_array($ch, array(
        CURLOPT_RETURNTRANSFER  => 1,
        CURLOPT_FOLLOWLOCATION  => 1,
        CURLOPT_SSL_VERIFYPEER  => 0,
        CURLOPT_NOBODY          => 1,
    ));
    curl_exec($ch);
    $clen = curl_getinfo($ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD);
    curl_close($ch);
    if (!$clen) {
        return 0;
    }else if($clen == -1){
        return 0;
    }else{
        return 1;
    }
}
echo isItAFile("http://google.com");

OFC this is not the final answer, this is not even close to what I wanted only a way around it but this is the best I got. If any of you guys know any good way please help out. I'm new to php and to stackoverflow. Sorry for my bad english