<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: PHP- Count Files In A Directory</title>
	<atom:link href="http://www.brightcherry.co.uk/scribbles/2008/09/06/php-count-files-in-a-directory/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.brightcherry.co.uk/scribbles/2008/09/06/php-count-files-in-a-directory/</link>
	<description></description>
	<lastBuildDate>Wed, 25 Aug 2010 19:01:17 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
	<item>
		<title>By: Maruf</title>
		<link>http://www.brightcherry.co.uk/scribbles/2008/09/06/php-count-files-in-a-directory/comment-page-1/#comment-918</link>
		<dc:creator>Maruf</dc:creator>
		<pubDate>Thu, 18 Feb 2010 19:58:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.brightcherry.co.uk/scribbles/?p=27#comment-918</guid>
		<description>Hey Pim,

I&#039;ve actually experienced that problem before.

Many thanks for sharing your solution :)

Great stuff!</description>
		<content:encoded><![CDATA[<p>Hey Pim,</p>
<p>I&#8217;ve actually experienced that problem before.</p>
<p>Many thanks for sharing your solution <img src='http://www.brightcherry.co.uk/scribbles/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Great stuff!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Maruf</title>
		<link>http://www.brightcherry.co.uk/scribbles/2008/09/06/php-count-files-in-a-directory/comment-page-1/#comment-917</link>
		<dc:creator>Maruf</dc:creator>
		<pubDate>Thu, 18 Feb 2010 19:57:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.brightcherry.co.uk/scribbles/?p=27#comment-917</guid>
		<description>Hey Soloman,

I&#039;m not entirely sure why you needed to use array_push there. Regardless, I have already written a post on how you get the files names here: http://www.brightcherry.co.uk/scribbles/2008/11/02/php-list-all-files-in-a-directory/

:)</description>
		<content:encoded><![CDATA[<p>Hey Soloman,</p>
<p>I&#8217;m not entirely sure why you needed to use array_push there. Regardless, I have already written a post on how you get the files names here: <a href="http://www.brightcherry.co.uk/scribbles/2008/11/02/php-list-all-files-in-a-directory/" rel="nofollow">http://www.brightcherry.co.uk/scribbles/2008/11/02/php-list-all-files-in-a-directory/</a></p>
<p> <img src='http://www.brightcherry.co.uk/scribbles/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Solomon</title>
		<link>http://www.brightcherry.co.uk/scribbles/2008/09/06/php-count-files-in-a-directory/comment-page-1/#comment-916</link>
		<dc:creator>Solomon</dc:creator>
		<pubDate>Thu, 18 Feb 2010 11:47:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.brightcherry.co.uk/scribbles/?p=27#comment-916</guid>
		<description>Wow! I can&#039;t count the number of times I&#039;ve been digging around the internet for the same old &quot;bloated&quot; script because I&#039;ve never actually bothered leaning it by heart. If I&#039;d have done my research a little better I would have found this solution years ago! Simple, elegant, and it just plain works!

I needed the a script to return the filenames too, regardless of their extension. This is my take on it... I hope someone finds it helpful:

# code to return an array of file paths from a directory
$filepath = $pathtodirectory . &quot;*&quot;;
$filenames = array();
foreach (glob($filepath) as $filename) {
  array_push($filenames , $filename);
}
print_r($filenames);


I learnt that the path can be relative but it shouldn&#039;t have a leading slash. Also the &quot;*&quot; on the end of the filepath catches all files.</description>
		<content:encoded><![CDATA[<p>Wow! I can&#8217;t count the number of times I&#8217;ve been digging around the internet for the same old &#8220;bloated&#8221; script because I&#8217;ve never actually bothered leaning it by heart. If I&#8217;d have done my research a little better I would have found this solution years ago! Simple, elegant, and it just plain works!</p>
<p>I needed the a script to return the filenames too, regardless of their extension. This is my take on it&#8230; I hope someone finds it helpful:</p>
<p># code to return an array of file paths from a directory<br />
$filepath = $pathtodirectory . &#8220;*&#8221;;<br />
$filenames = array();<br />
foreach (glob($filepath) as $filename) {<br />
  array_push($filenames , $filename);<br />
}<br />
print_r($filenames);</p>
<p>I learnt that the path can be relative but it shouldn&#8217;t have a leading slash. Also the &#8220;*&#8221; on the end of the filepath catches all files.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pim</title>
		<link>http://www.brightcherry.co.uk/scribbles/2008/09/06/php-count-files-in-a-directory/comment-page-1/#comment-900</link>
		<dc:creator>Pim</dc:creator>
		<pubDate>Wed, 03 Feb 2010 11:03:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.brightcherry.co.uk/scribbles/?p=27#comment-900</guid>
		<description>Thanks for the code. However I found that when there are 0 files it still returns 1. I fixed it with an if statement:

&lt;CODE&gt;
//Count .jpg
			
if (glob(&quot;&quot; . $directory . &quot;*.jpg&quot;) != false)
			$filecount = count(glob(&quot;&quot; . $directory . &quot;*.jpg&quot;));
			else
			$filecount = 0;
&lt;/CODE&gt;

Maybe this helps some people struggeling with the same issue.</description>
		<content:encoded><![CDATA[<p>Thanks for the code. However I found that when there are 0 files it still returns 1. I fixed it with an if statement:</p>
<p><code><br />
//Count .jpg</p>
<p>if (glob(&#8220;&#8221; . $directory . &#8220;*.jpg&#8221;) != false)<br />
			$filecount = count(glob(&#8220;&#8221; . $directory . &#8220;*.jpg&#8221;));<br />
			else<br />
			$filecount = 0;<br />
</code></p>
<p>Maybe this helps some people struggeling with the same issue.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: shiva</title>
		<link>http://www.brightcherry.co.uk/scribbles/2008/09/06/php-count-files-in-a-directory/comment-page-1/#comment-885</link>
		<dc:creator>shiva</dc:creator>
		<pubDate>Wed, 13 Jan 2010 07:01:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.brightcherry.co.uk/scribbles/?p=27#comment-885</guid>
		<description>Masha Allah ...lovely code Thanks ...Maruf</description>
		<content:encoded><![CDATA[<p>Masha Allah &#8230;lovely code Thanks &#8230;Maruf</p>
]]></content:encoded>
	</item>
</channel>
</rss>
