View Single Post
Old 10-05-2012, 05:06 PM   PM User | #5
LJackson
Senior Coder

 
Join Date: Jun 2008
Location: Cornwall
Posts: 1,973
Thanks: 289
Thanked 12 Times in 12 Posts
LJackson is on a distinguished road
ok thanks for the above,

i have added the function to my page and added these two lines in my while loop
PHP Code:
$aItems scandir($directory);
$aItemsFiltered array_filter($aItems'filterArrayOnlyDirectories'); 
like so
PHP Code:
                    #get portfolio categories
                    if ($handle = opendir('portfolio'))
                    {
                        #echo "Directory handle: $handle\n";
                        #echo "Entries:\n";
                        $x = 1;
                        /* This is the correct way to loop over the directory. */
                        while (false !== ($entry = readdir($handle)))
                        {
                        
                            #echo $entry;
                            if ($entry != "." && $entry != "..") 
                            {
                            
                                #count folders inside directorys
                                $directory = "portfolio/$entry";
                                $aItems = scandir($directory);
                                $aItemsFiltered = array_filter($aItems, 'filterArrayOnlyDirectories');
                                                                
                                if (($x % 3) == 0)
                                {
                                    $className = "col-2";
                                }
                                else
                                {
                                    $className = "col-1";
                                }
                                
                                ?>
                                <div class="<?php echo $className?>">
                                    <figure class="img-box">
                                        <a href="portfolio-weddings.html">
                                            <img src="images/page3-img1.jpg" alt="">
                                        </a>
                                    </figure>
                                    <div class="gallery-meta">
                                        <a href="#" class="gallery-name"><?php echo ucwords($entry);?></a>
                                        <span class="capacity">(<?php echo count($aItemsFiltered); ?> Albums)</span>
                                    </div>
                                </div><?php
                                $x
++;
                            }
                        }
                                
                        
closedir($handle);
                    }
?>
i tried to echo out $aItemsFiltered and it returned 'array' so i then tried echo count($aItemsFiltered) and it always returns 0 even though at least on of my directories has a folder within it?

am i using it correctly? maybe my loop is incorrect?

cheers mate
Luke
__________________
Kernow Connect: Online Shopping, Price Comparison, Maximum Savings On Top UK Stores
Follow Us On: Twitter | Facebook

Last edited by LJackson; 10-05-2012 at 05:14 PM..
LJackson is offline   Reply With Quote