<?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>Side Notes &#187; auslesen</title>
	<atom:link href="http://blog.snaky.org/tag/auslesen/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.snaky.org</link>
	<description>Relax, its only ONES and ZEROS!</description>
	<lastBuildDate>Sun, 11 Oct 2009 12:20:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
<image>
<link>http://blog.snaky.org</link>
<url>http://blog.snaky.org/wp-content/plugins/maxblogpress-favicon/icons/favicon-26.ico</url>
<title>Side Notes</title>
</image>
		<item>
		<title>Verzeichnis rekursiv auslesen (mit Dateigröße)</title>
		<link>http://blog.snaky.org/2008/09/12/verzeichnis-rekursiv-auslesen-mit-dateigrose/</link>
		<comments>http://blog.snaky.org/2008/09/12/verzeichnis-rekursiv-auslesen-mit-dateigrose/#comments</comments>
		<pubDate>Fri, 12 Sep 2008 15:07:47 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[auslesen]]></category>
		<category><![CDATA[funktion]]></category>
		<category><![CDATA[rekursiv]]></category>
		<category><![CDATA[Verzeichnis]]></category>

		<guid isPermaLink="false">http://blog.snaky.org/?p=81</guid>
		<description><![CDATA[<img src="http://blog.snaky.org/wp-content/uploads/2008/07/php_16.png" width="16" height="16" alt="" title="PHP" /><br/>Ein Verzeichnis rekursiv mit PHP auszulesen bedarf es nicht viel. Hier habe ich ein beispiel mit lediglich 3 kleinen Funktionen. Die Erste gibt eine lesbare Dateigröße aus Die zweite Funktion definiert, wie die Dateien angezeigt werden sollen Die Dritte Liest die Ordner aus und ruft gegebenenfalls Sich slebst mit neuem Parameter auf function byteConvert&#40;$bytes&#41;&#123; $symbol [...]]]></description>
			<content:encoded><![CDATA[<img src="http://blog.snaky.org/wp-content/uploads/2008/07/php_16.png" width="16" height="16" alt="" title="PHP" /><br/><p>Ein Verzeichnis rekursiv mit PHP auszulesen bedarf es nicht viel.</p>
<p>Hier habe ich ein beispiel mit lediglich 3 kleinen Funktionen.</p>
<ul>
<li> Die Erste gibt eine lesbare Dateigröße aus</li>
<li>Die zweite Funktion definiert, wie die Dateien angezeigt werden sollen</li>
<li>Die Dritte Liest die Ordner aus und ruft gegebenenfalls Sich slebst mit neuem Parameter auf</li>
</ul>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> byteConvert<span style="color: #009900;">&#40;</span><span style="color: #000088;">$bytes</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$symbol</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'B'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'KB'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'MB'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'GB'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'TB'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'PB'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'EB'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'ZB'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'YB'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$exp</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$converted_value</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$bytes</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$exp</span> <span style="color: #339933;">=</span> <span style="color: #990000;">floor</span><span style="color: #009900;">&#40;</span> <span style="color: #990000;">log</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$bytes</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span><span style="color: #990000;">log</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1000</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$converted_value</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$bytes</span><span style="color: #339933;">/</span><span style="color: #990000;">pow</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1000</span><span style="color: #339933;">,</span><span style="color: #990000;">floor</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$exp</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'%.2f '</span><span style="color: #339933;">.</span><span style="color: #000088;">$symbol</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$exp</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$converted_value</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">function</span> file_detail<span style="color: #009900;">&#40;</span><span style="color: #000088;">$dir</span><span style="color: #339933;">,</span><span style="color: #000088;">$name</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$stat</span> <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><span style="color: #990000;">stat</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dir</span><span style="color: #339933;">.</span><span style="color: #000088;">$name</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">#print_r($stat);
</span>	<span style="color: #000088;">$returner</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;td&gt;<span style="color: #006699; font-weight: bold;">$name</span>&lt;/td&gt;&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$returner</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;td&gt;&quot;</span><span style="color: #339933;">.</span>byteConvert<span style="color: #009900;">&#40;</span><span style="color: #000088;">$stat</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'size'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/td&gt;&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$returner</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">function</span> rec_scan_dir<span style="color: #009900;">&#40;</span><span style="color: #000088;">$dir</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$returner</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;table&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$files</span> <span style="color: #339933;">=</span> <span style="color: #990000;">scandir</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$dir</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">sort</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$files</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$files</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$file</span><span style="color: #339933;">!=</span><span style="color: #0000ff;">&quot;.&quot;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$file</span><span style="color: #339933;">!=</span><span style="color: #0000ff;">&quot;..&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">is_dir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dir</span><span style="color: #339933;">.</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$returner</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;tr&gt;&lt;td class='dir'&gt;<span style="color: #006699; font-weight: bold;">$file</span>&lt;/td&gt;&lt;/tr&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
				<span style="color: #000088;">$returner</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;tr&gt;&lt;td&gt;&lt;div class='dir_pad' style='padding-left:10px;'&gt;&quot;</span><span style="color: #339933;">.</span>rec_scan_dir<span style="color: #009900;">&#40;</span><span style="color: #000088;">$dir</span><span style="color: #339933;">.</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$returner</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;tr&gt;&quot;</span><span style="color: #339933;">;</span>
				<span style="color: #000088;">$returner</span> <span style="color: #339933;">.=</span> file_detail<span style="color: #009900;">&#40;</span><span style="color: #000088;">$dir</span><span style="color: #339933;">,</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000088;">$returner</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;/tr&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000088;">$returner</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;/table&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$returner</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$dir</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'./files/'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;h1&gt;<span style="color: #006699; font-weight: bold;">$dir</span>&lt;/h1&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span>rec_scan_dir<span style="color: #009900;">&#40;</span><span style="color: #000088;">$dir</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.snaky.org/2008/09/12/verzeichnis-rekursiv-auslesen-mit-dateigrose/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
