Question: ```
        $za = new ZipArchive();
        $za->open($source);
        for( $i = 0; $i < $za->numFiles; $i++ ){
            $stat = $za->statIndex( $i );
            $items = array( basename( $stat['name'] ) . PHP_EOL );
            foreach($items as $item) {
            echo $item;
            }
        }

```

This code will list all files inside a zip archive but i want to exclude folders listing. If the item in the array is a folder, i want to exclude it from the array BUT i still want to list the files inside the folder. Just don't display the folder's name in the list.

Is there a way i can detect if the item is a directory in my foreach loop (how?) or do i need to run a search on the array and look for folders then unset it (how?) ?

Thanks for your help

Answer: 
Your foreach is useless. It iteratate over array with one item.

Anyway there is two way to detect folder. First, folders are ended with '/'. Second folders has 0 size.

```
$za = new ZipArchive();
$za->open('zip.zip');
$result_stats = array();
for ($i = 0; $i < $za->numFiles; $i++)
    {
    $stat = $za->statIndex($i);
    if ($stat['size'])
        $result_stats[] = $stat;
    }

echo count($result_stats);

```
Directories have a trailling slash:

```
$za = new ZipArchive();
$za->open($source);
for( $i = 0; $i < $za->numFiles; $i++ ){
    $stat = $za->statIndex( $i );
    if(substr($stat['name'], -1) !== '/'){
        echo $stat['name'];
    }
}

```