View Single Post
Old 10-05-2012, 04:28 PM   PM User | #1
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
Exclamation please help me to count the number of folders with in directories

Hi All,

I am listing all the 'categories' with in a directory which is working now i want to try and find out the number of "folders" with in each of the category directories

here is my code
PHP Code:
               <?php
                    
#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;
                                
###end count folders inside directories

                                                                
                                
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?> Albums)</span>
                                    </div>
                                </div><?php
                                $x
++;
                            }
                        }
                                
                        
closedir($handle);
                    }
?>
i've got up to the point of setting the individual categories now i need to figure out how to count the number of folders within these directories

can anyone help me please
thanks
Luke
__________________
Kernow Connect: Online Shopping, Price Comparison, Maximum Savings On Top UK Stores
Follow Us On: Twitter | Facebook
LJackson is offline   Reply With Quote