<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>NewSourceMedia Blog &#187; Files and Folders</title>
	<atom:link href="http://newsourcemedia.com/blog/category/php/files-and-folders/feed/" rel="self" type="application/rss+xml" />
	<link>http://newsourcemedia.com/blog</link>
	<description>Focused on Interactive Design, Development and Marketing</description>
	<lastBuildDate>Mon, 07 May 2012 01:26:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Sort Directory Listings</title>
		<link>http://newsourcemedia.com/blog/sort-directory-listings/</link>
		<comments>http://newsourcemedia.com/blog/sort-directory-listings/#comments</comments>
		<pubDate>Tue, 02 Dec 2003 00:22:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CMS]]></category>
		<category><![CDATA[Files and Folders]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://newsourcemedia.com/blog/1969/12/31/sort-directory-listings/</guid>
		<description><![CDATA[Here is some code to help sort the order of your directory output. This is greate for creating PHP FTP applications. sort() General Example 1. $fruits = array("lemon", "orange", "banana", "apple"); sort($fruits); reset($fruits); while (list($key, $val) = each($fruits)) { echo &#8230; <a href="http://newsourcemedia.com/blog/sort-directory-listings/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[Here is some code to help sort the order of your directory output. This is greate for creating PHP FTP applications.
<span id="more-236"></span>

<strong> <span style="color: #006600; font-size: large;">sort()</span></strong>

<strong>General Example 1.</strong>

<span style="color: #ff6600;"> $fruits = array("lemon", "orange", "banana", "apple");
sort($fruits);
reset($fruits);
while (list($key, $val) = each($fruits)) {
echo "fruits = ".$val."\n";
}
?&gt;</span>

<strong>Directory Example 1. A simple scandir() example</strong>

<span style="color: #ff6600;"> $dir = '/tmp';
$files1 = scandir($dir);
$files2 = scandir($dir, 1);
print_r($files1);
print_r($files2);</span>
<span style="color: #666666;">/* Outputs something like:
Array
(
 =&gt; .
 =&gt; ..
 =&gt; bar.php
 =&gt; foo.txt
 =&gt; somedir
)
Array
(
 =&gt; somedir
 =&gt; foo.txt
 =&gt; bar.php
 =&gt; ..
 =&gt; .
)
*/</span>
<span style="color: #ff6600;">?&gt;</span>

<strong>Directory Example 2. PHP 4 alternatives to scandir()</strong>

<span style="color: #ff6600;"> $dir = "/tmp";
$dh = opendir($dir);
while (false !== ($filename = readdir($dh))) {
$files = $filename;
}
sort($files);
print_r($files);
rsort($files);
print_r($files);</span>
<span style="color: #666666;">/* Outputs something like:
Array
(
 =&gt; .
 =&gt; ..
 =&gt; bar.php
 =&gt; foo.txt
 =&gt; somedir
)
Array
(
 =&gt; somedir
 =&gt; foo.txt
 =&gt; bar.php
 =&gt; ..
 =&gt; .
)
*/</span>
<span style="color: #ff6600;">?&gt; </span>]]></content:encoded>
			<wfw:commentRss>http://newsourcemedia.com/blog/sort-directory-listings/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
