<?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>PHP Reference Book Blog &#187; getcwd</title>
	<atom:link href="http://www.phpreferencebook.com/tag/getcwd/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.phpreferencebook.com</link>
	<description>PHP Reference: Beginner to Intermediate PHP5</description>
	<lastBuildDate>Thu, 29 Sep 2011 03:50:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Quick Tip: getcwd() for Contents of Current Directory</title>
		<link>http://www.phpreferencebook.com/tips/getcwd-scandir-get-display-contents-current-directory/</link>
		<comments>http://www.phpreferencebook.com/tips/getcwd-scandir-get-display-contents-current-directory/#comments</comments>
		<pubDate>Tue, 22 Dec 2009 14:00:52 +0000</pubDate>
		<dc:creator>Mario Lurig</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[getcwd]]></category>
		<category><![CDATA[scandir]]></category>
		<category><![CDATA[tip]]></category>

		<guid isPermaLink="false">http://www.phpreferencebook.com/?p=352</guid>
		<description><![CDATA[The getcwd() function is short for &#8216;GET Current Working Directory&#8217;. This can easily be combined with the scandir() function which returns an array of all the files and directories inside the specified directory. This tip was excluded from the book as an oversight. &#160; A quick way to get a list of all the contents [...]]]></description>
			<content:encoded><![CDATA[<p>The getcwd() function is short for &#8216;GET Current Working Directory&#8217;. This can easily be combined with the scandir() function which returns an array of all the files and directories inside the specified directory. This tip was excluded from the book as an oversight.<br />
&nbsp;<br />
A quick way to get a list of all the contents of the current directory is to use the following code:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> preprint<span style="color: #009900;">&#40;</span><span style="color: #000088;">$arr</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt; pre&gt;'</span><span style="color: #339933;">.</span><span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$arr</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt; /pre&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000088;">$array</span> <span style="color: #339933;">=</span> <span style="color: #990000;">scandir</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">getcwd</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
preprint<span style="color: #009900;">&#40;</span><span style="color: #000088;">$array</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// nicely formatted display of the array</span></pre></div></div>

<p>&nbsp;<br />
Of course, you can skip the print/echo portion if you don&#8217;t wish to display the contents and just use the array to perform other checks, but you get the idea.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpreferencebook.com/tips/getcwd-scandir-get-display-contents-current-directory/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

