<?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>FaraJoomla Web Design and Development &#187; PHP</title>
	<atom:link href="http://www.farajoomla.com/category/blog/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.farajoomla.com</link>
	<description>FaraJoomla Web Design and Development</description>
	<lastBuildDate>Sat, 29 Oct 2011 17:49:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Useing glob() to Find Pathnames</title>
		<link>http://www.farajoomla.com/2010/05/useing-glob-to-find-pathnames/</link>
		<comments>http://www.farajoomla.com/2010/05/useing-glob-to-find-pathnames/#comments</comments>
		<pubDate>Wed, 12 May 2010 02:47:35 +0000</pubDate>
		<dc:creator>Faramarz</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.farajoomla.com/?p=291</guid>
		<description><![CDATA[The glob() function searches for all the pathnames matching pattern according to the rules used by the libc glob() function, which is similar to the rules used by common shells. The downside of this function is it will not work on remote files as the file to be examined must be accessible via the server&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>The glob() function searches for all the pathnames matching pattern according to the rules used by the libc glob() function, which is similar to the rules used by common shells.</p>
<p>The downside of this function is it will not work on remote files as the file to be examined must be accessible via the server&#8217;s filesystem and it isn&#8217;t available on some systems (e.g. old Sun OS). </p>
<h2>glob()</h2>
<pre class="brush: php">
  array glob  (  string $pattern  [,  int $flags = 0  ] )
</pre>
<h2>Pattern</h2>
<p>The pattern. No tilde expansion or parameter substitution is done. </p>
<h2>Flags</h2>
<ul>
<li> GLOB_MARK &#8211; Adds a slash to each directory returned</li>
<li> GLOB_NOSORT &#8211; Return files as they appear in the directory (no sorting)</li>
<li> GLOB_NOCHECK &#8211; Return the search pattern if no files matching it were found</li>
<li> GLOB_NOESCAPE &#8211; Backslashes do not quote metacharacters</li>
<li> GLOB_BRACE &#8211; Expands {a,b,c} to match &#8216;a&#8217;, &#8216;b&#8217;, or &#8216;c&#8217;</li>
<li> GLOB_ONLYDIR &#8211; Return only directory entries which match the pattern</li>
<li> GLOB_ERR &#8211; Stop on read errors (like unreadable directories), by default errors are ignored.</li>
</ul>
<h2>Return Values</h2>
<p>Returns an array containing the matched files/directories, an empty array if no file matched or FALSE on error. <br />
  Note: On some systems it is impossible to distinguish between empty match and an error. </p>
<h2>Example</h2>
<pre class="brush: php">
  &lt;?php
  foreach (glob(&quot;*.txt&quot;) as $filename) {
  echo &quot;$filename size &quot; . filesize($filename) . &quot;\n&quot;;
  }
  ?&gt;
  </pre>
<p>It works like scandir() function but it is more capable and flexible. It can let you search for files by using patterns.</p>
<pre class="brush: php">
  $files = glob(&#039;*.php&#039;);
  print_r($files);
Array
  (
  [0] =&gt; phptest.php
  [1] =&gt; pi.php
  [2] =&gt; post_output.php
  [3] =&gt; test.php
  )
</pre>
<p>And to fetch multiple file types, you should use it like this:</p>
<pre class="brush: php">
  $files = glob(&#039;*.{php,txt}&#039;, GLOB_BRACE);
  print_r($files);
  Array
  (
  [0] =&gt; phptest.php
  [1] =&gt; pi.php
  [2] =&gt; post_output.php
  [3] =&gt; test.php
  [4] =&gt; log.txt
  5] =&gt; test.txt
  )
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.farajoomla.com/2010/05/useing-glob-to-find-pathnames/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

