<?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>TSQL - Transact SQL - C#, PHP, Visual Basic, C++</title>
	<atom:link href="http://www.tsql.de/feed" rel="self" type="application/rss+xml" />
	<link>http://www.tsql.de</link>
	<description>TSQL Transact SQL und SQL in Verbindung mit Progammiersprachen wie c#,csharp,c++,cplusplus,visual basic, vb, php.</description>
	<lastBuildDate>Sun, 12 May 2013 11:06:51 +0000</lastBuildDate>
	<language>de-DE</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>IP2LONG</title>
		<link>http://www.tsql.de/tools/ip2long-online</link>
		<comments>http://www.tsql.de/tools/ip2long-online#comments</comments>
		<pubDate>Sun, 12 May 2013 11:03:05 +0000</pubDate>
		<dc:creator>Michael Klaus</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[ip]]></category>
		<category><![CDATA[ip2long]]></category>

		<guid isPermaLink="false">http://www.tsql.de/?p=2260</guid>
		<description><![CDATA[IPv4 Adresse mit der PHP Funktion ip2long()  in einen Long-Wert mit umwandeln.]]></description>
				<content:encoded><![CDATA[<form action="http://www.tsql.de/tools/ip2long-online">IP: <input type="text" name="ip" value="" /><input type="submit" value="IP wandeln" /></form>
<p>Beispiele:</p>
<table>
<tr>
<th>String</th>
<th>MD5 Hash</th>
</tr>
<tr>
<td><a href="http://www.tsql.de/tools/ip2long-online?ip=127.0.0.1">127.0.0.1</a></td>
<td>2130706433</td>
</tr>
<tr>
<td><a href="http://www.tsql.de/tools/ip2long-online?ip=192.168.1.1">192.168.1.1</a></td>
<td>-1062731519</td>
</tr>
<tr>
<td><a href="http://www.tsql.de/tools/ip2long-online?ip=192.168.2.1">192.168.2.1</a></td>
<td>-1062731263</td>
</tr>
</table>
]]></content:encoded>
			<wfw:commentRss>http://www.tsql.de/tools/ip2long-online/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MD5 Generator</title>
		<link>http://www.tsql.de/tools/md5-online-generator</link>
		<comments>http://www.tsql.de/tools/md5-online-generator#comments</comments>
		<pubDate>Fri, 03 May 2013 19:51:11 +0000</pubDate>
		<dc:creator>Michael Klaus</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[md5]]></category>

		<guid isPermaLink="false">http://www.tsql.de/?p=2231</guid>
		<description><![CDATA[MD5 Online erstellen. Hier können MD5 Prüfsummen erstellt werden. Die Erstellung erfolgt mit der PHP Funktion md5().]]></description>
				<content:encoded><![CDATA[<form action="http://www.tsql.de/tools/md5-online-generator">Text: <input type="text" name="md5" value="" /><input type="submit" value="MD5 generieren" /></form>
<p>Beispiele:</p>
<table>
<tr>
<th>String</th>
<th>MD5 Hash</th>
</tr>
<tr>
<td><a href="http://www.tsql.de/tools/md5-online-generator?md5=Sonntag">Sonntag</a></td>
<td>35cb2d80a11eadd1c880fc69cb852f76</td>
</tr>
<tr>
<td><a href="http://www.tsql.de/tools/md5-online-generator?md5=Montag">Montag</a></td>
<td>5ba92fd9fe06536b98e6ab7b19531d8f</td>
</tr>
<tr>
<td><a href="http://www.tsql.de/tools/md5-online-generator?md5=Dienstag">Dienstag</a></td>
<td>af5b4a59f444f0b452421dcf5238f781</td>
</tr>
<tr>
<td><a href="http://www.tsql.de/tools/md5-online-generator?md5=Mittwoch">Mittwoch</a></td>
<td>c7ce86340399fcbc38c020a090e5f227</td>
</tr>
<tr>
<td><a href="http://www.tsql.de/tools/md5-online-generator?md5=Donnerstag">Donnerstag</a></td>
<td>c4c15efd19d7e642741a346807510abe</td>
</tr>
<tr>
<td><a href="http://www.tsql.de/tools/md5-online-generator?md5=Freitag">Freitag</a></td>
<td>8e968f5fc3fddc3f1c7d9510b22b4ada</td>
</tr>
<tr>
<td><a href="http://www.tsql.de/tools/md5-online-generator?md5=Samstag">Samstag</a></td>
<td>f3e9b5cbb5bfb05906a402de29d7ee6f</td>
</tr>
<tr>
<td><a href="http://www.tsql.de/tools/md5-online-generator?md5=Hans">Hans</a></td>
<td>eb56002f1c0a8f9ab1b2aa2d08a1c502</td>
</tr>
<tr>
<td><a href="http://www.tsql.de/tools/md5-online-generator?md5=Maik">Maik</a></td>
<td>891cba28db18ac67b12d9b81a38440e8</td>
</tr>
<tr>
<td><a href="http://www.tsql.de/tools/md5-online-generator?md5=Peter">Peter</a></td>
<td>6fa95b1427af77b3d769ae9cb853382f</td>
</tr>
</table>
]]></content:encoded>
			<wfw:commentRss>http://www.tsql.de/tools/md5-online-generator/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP MD5</title>
		<link>http://www.tsql.de/php/php-md5</link>
		<comments>http://www.tsql.de/php/php-md5#comments</comments>
		<pubDate>Fri, 03 May 2013 19:40:33 +0000</pubDate>
		<dc:creator>Michael Klaus</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[md5]]></category>

		<guid isPermaLink="false">http://www.tsql.de/?p=2225</guid>
		<description><![CDATA[MD5 Strings können in PHP mit der Funktion md5(&#8220;string&#8221;) erzeugt werden. Folgendes Skript, wandelt die Zeichenkette &#8220;Mein Passwort&#8221; in den MD5-String &#8220;578127b714de227824ab105689da0ed2&#8243; um. Beispiel: $passwort = 'Mein Passwort'; $md5_passwort = md5&#40;$passwort&#41;; MD5 Online rechnen.]]></description>
				<content:encoded><![CDATA[<p>MD5 Strings können in PHP mit der Funktion md5(&#8220;string&#8221;) erzeugt werden. Folgendes Skript, wandelt die Zeichenkette &#8220;Mein Passwort&#8221; in den MD5-String &#8220;578127b714de227824ab105689da0ed2&#8243; um.</p>
<p>Beispiel:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$passwort</span>   <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Mein Passwort'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$md5_passwort</span> <span style="color: #339933;">=</span> <span style="color: #990000;">md5</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$passwort</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p><a href="http://www.tsql.de/tools/md5-online-generator">MD5 Online rechnen.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tsql.de/php/php-md5/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Mehrdimensionale Arrays</title>
		<link>http://www.tsql.de/php/mehrdimensionale-array</link>
		<comments>http://www.tsql.de/php/mehrdimensionale-array#comments</comments>
		<pubDate>Fri, 26 Apr 2013 14:13:59 +0000</pubDate>
		<dc:creator>Michael Klaus</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[sortieren]]></category>

		<guid isPermaLink="false">http://www.tsql.de/?p=2195</guid>
		<description><![CDATA[Mehrdimensionale Arrays mit der Funktion array_multisort sortieren.]]></description>
				<content:encoded><![CDATA[<p>Mehrdimensionale Arrays zu sortieren bereitet gerade Einsteiger immer wieder Schwierigkeiten.<br />
Zuallererst bauen wir uns ein Array auf:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$array</span>   <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$array</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'vorname'</span><span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Hans'</span><span style="color: #339933;">,</span> 
                 <span style="color: #0000ff;">'name'</span>   <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Meier'</span><span style="color: #339933;">,</span> 
                 <span style="color: #0000ff;">'plz'</span>    <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'10119'</span><span style="color: #339933;">,</span> 
                 <span style="color: #0000ff;">'ort'</span>    <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Berlin'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$array</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'vorname'</span><span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Egon'</span><span style="color: #339933;">,</span> 
                 <span style="color: #0000ff;">'name'</span>   <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Schmidt'</span><span style="color: #339933;">,</span> 
                 <span style="color: #0000ff;">'plz'</span>    <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'01067'</span><span style="color: #339933;">,</span> 
                 <span style="color: #0000ff;">'ort'</span>    <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Dresden'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$array</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'vorname'</span><span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Franz'</span><span style="color: #339933;">,</span> 
                 <span style="color: #0000ff;">'name'</span>   <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Müller'</span><span style="color: #339933;">,</span>
                 <span style="color: #0000ff;">'plz'</span>    <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'50670'</span><span style="color: #339933;">,</span> 
                 <span style="color: #0000ff;">'ort'</span>    <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Köln'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Zur Vorbereitung auf die Sortierung, erstellen wir im nächsten Schritt ein Hilfsarray.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$array</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$hilfsarray_vorname</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#93;</span>  <span style="color: #339933;">=</span>  <span style="color: #000088;">$value</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'vorname'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$hilfsarray_name</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#93;</span>     <span style="color: #339933;">=</span>  <span style="color: #000088;">$value</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$hilfsarray_plz</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#93;</span>      <span style="color: #339933;">=</span>  <span style="color: #000088;">$value</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'plz'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$hilfsarray_ort</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#93;</span>      <span style="color: #339933;">=</span>  <span style="color: #000088;">$value</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'ort'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<h2>Einfache Sortierung</h2>
<p>Die Variable $array wird direkt sortiert.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// sortieren nach Vorname</span>
<span style="color: #990000;">array_multisort</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$hilfsarray_vorname</span><span style="color: #339933;">,</span> SORT_ASC<span style="color: #339933;">,</span> SORT_NATURAL<span style="color: #339933;">,</span> <span style="color: #000088;">$array</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// sortieren nach Name</span>
<span style="color: #990000;">array_multisort</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$hilfsarray_name</span><span style="color: #339933;">,</span> SORT_ASC<span style="color: #339933;">,</span> SORT_NATURAL<span style="color: #339933;">,</span> <span style="color: #000088;">$array</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// sortieren nach Plz</span>
<span style="color: #990000;">array_multisort</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$hilfsarray_plz</span><span style="color: #339933;">,</span> SORT_ASC<span style="color: #339933;">,</span> SORT_NUMERIC<span style="color: #339933;">,</span> <span style="color: #000088;">$array</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// sortieren nach Ort</span>
<span style="color: #990000;">array_multisort</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$hilfsarray_ort</span><span style="color: #339933;">,</span> SORT_ASC<span style="color: #339933;">,</span> SORT_NATURAL<span style="color: #339933;">,</span> <span style="color: #000088;">$array</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h2>Mehrfache Sortierung</h2>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// sortieren nach Vorname aufsteigend und Name absteigend</span>
<span style="color: #990000;">array_multisort</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$hilfsarray_vorname</span><span style="color: #339933;">,</span> SORT_ASC<span style="color: #339933;">,</span> SORT_NATURAL<span style="color: #339933;">,</span> <span style="color: #000088;">$hilfsarray_name</span><span style="color: #339933;">,</span> SORT_DESC<span style="color: #339933;">,</span> SORT_NATURAL<span style="color: #339933;">,</span> <span style="color: #000088;">$array</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// sortieren nach Plz absteigend und Ort aufsteigend</span>
<span style="color: #990000;">array_multisort</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$hilfsarray_plz</span><span style="color: #339933;">,</span> SORT_DESC<span style="color: #339933;">,</span> SORT_NUMERIC<span style="color: #339933;">,</span> <span style="color: #000088;">$hilfsarray_ort</span><span style="color: #339933;">,</span> SORT_ASC<span style="color: #339933;">,</span> SORT_NATURAL<span style="color: #339933;">,</span> <span style="color: #000088;">$array</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h3>Hinweis</h3>
<p>PHP unterstützt erst ab Version 5.4 das FLAG &#8220;SORT_NATURAL&#8221;. Als Workaround bietet es sich an, bei der Erzeugung wie folgt einzugreifen:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$array</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$hilfsarray_vorname</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#93;</span>  <span style="color: #339933;">=</span>  <span style="color: #990000;">strtolower</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$value</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'vorname'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$hilfsarray_name</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#93;</span>     <span style="color: #339933;">=</span>  <span style="color: #990000;">strtolower</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$value</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$hilfsarray_plz</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#93;</span>      <span style="color: #339933;">=</span>  <span style="color: #990000;">strtolower</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$value</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'plz'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$hilfsarray_ort</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#93;</span>      <span style="color: #339933;">=</span>  <span style="color: #990000;">strtolower</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$value</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'ort'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Alternativ kann auch die Funktion &#8220;array_map&#8221; ein komplettes Array in Kleinbuchstaben umwandeln:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$hilfsarray_vorname</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_map</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'strtolower'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$hilfsarray_vorname</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.tsql.de/php/mehrdimensionale-array/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Themenvorschläge</title>
		<link>http://www.tsql.de/forum/themenvorschlage</link>
		<comments>http://www.tsql.de/forum/themenvorschlage#comments</comments>
		<pubDate>Wed, 03 Oct 2012 11:24:21 +0000</pubDate>
		<dc:creator>Michael Klaus</dc:creator>
				<category><![CDATA[Forum]]></category>

		<guid isPermaLink="false">http://www.tsql.de/?p=2172</guid>
		<description><![CDATA[Demnächst möchte ich an dieser Stelle ein Forum bereitstellen. Bevor es aber losgeht, stellt sich die Frage, welche Themen, Kategorien hier behandelt werden sollen.]]></description>
				<content:encoded><![CDATA[<p>Demnächst möchte ich an dieser Stelle ein Forum bereitstellen. Bevor es aber losgeht, stellt sich die Frage, welche Themen, Kategorien hier behandelt werden sollen. Hinterlasst Eure Wünsche als einfach Kommentar.</p>
<p>Vielen Dank</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tsql.de/forum/themenvorschlage/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Reguläre Ausdrücke, REGEX oder PREG</title>
		<link>http://www.tsql.de/php/php_preg_regex_regulaerer_ausdruck</link>
		<comments>http://www.tsql.de/php/php_preg_regex_regulaerer_ausdruck#comments</comments>
		<pubDate>Wed, 16 Feb 2011 20:40:22 +0000</pubDate>
		<dc:creator>Michael Klaus</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[preg]]></category>
		<category><![CDATA[reguläre ausdrücke]]></category>

		<guid isPermaLink="false">http://www.tsql.de/?p=1749</guid>
		<description><![CDATA[Reguläre Ausdrücke sind für viele ein rotes Tuch. In diesem Tipp habe ich daher einige Regex gesammelt. Überschrift einer Webseite ermitteln. Telefonnummer prüfen. Wiederholende Leerzeichen ersetzen. IP Adresse prüfen. Datumsangaben aus ein Text filtern]]></description>
				<content:encoded><![CDATA[<p>Reguläre Ausdrücke sind für viele ein rotes Tuch. In diesem Tipp habe ich daher einige Regex gesammelt. In PHP stehen mehrere Funktionen zur Verfügung, die mit regulären Ausdrücken &#8220;gefüttert&#8221; werden können. Hier eine kleine Übersicht:</p>
<table>
<tr>
<th>Funktion</th>
<th>Beschreibung</th>
</tr>
<tr>
<td>preg_filter</td>
<td>Sucht und ersetzt mit regulären Ausdrücken</td>
</tr>
<tr>
<td>preg_grep</td>
<td>Liefert Array-Elemente, die auf ein Suchmuster passen</td>
</tr>
<tr>
<td>preg_replace_callback</td>
<td>Sucht und ersetzt einen regulären Ausdruck unter Verwendung eines Callbacks</td>
</tr>
<tr>
<td>preg_match_all</td>
<td>Führt eine umfassende Suche nach Übereinstimmungen mit regulärem Ausdruck durch</td>
</tr>
<tr>
<td>preg_match</td>
<td>Führt eine Suche mit einem regulären Ausdruck durch</td>
</tr>
<tr>
<td>preg_replace</td>
<td>Sucht und ersetzt mit regulären Ausdrücken</td>
</tr>
<tr>
<td>preg_split</td>
<td>Zerlegt eine Zeichenkette anhand eines regulären Ausdrucks</td>
</tr>
<tr>
<td>preg_quote</td>
<td>Maskiert Zeichen regulärer Ausdrücke</td>
</tr>
</table>
<p>Als nächsten sehen wir einige einfache reguläre Ausdrücke und deren Bedeutung. Die Muster werden immer von einem Begrenzungszeichen (Delimiter) eingeschlossen. Bei der Auswahl des Delimiters ist darauf zu achten, dass dieses Zeichen nicht innerhalb des Musters vorkommt.<br />
Eine kleine Übersicht über Suchmuster:</p>
<table>
<tr>
<th>Regulärer Ausdruck (Pattern)</th>
<th>Sucht nach .. </th>
</tr>
<tr>
<td>[a-z]</td>
<td>einzelner Kleinbuchstabe</td>
</tr>
<tr>
<td>[A-Z]</td>
<td>einzelner Großbuchstabe</td>
</tr>
<tr>
<td>hallo</td>
<td>der String &#8220;hallo&#8221; wird gesucht</td>
</tr>
<tr>
<td>[a-z]+</td>
<td>ein oder mehrere Kleinbuchstaben</td>
</tr>
<tr>
<td>[g-z]</td>
<td>ein einzelner Kleinbuchstabe zwischen &#8220;g&#8221; und &#8220;z&#8221;</td>
</tr>
<tr>
<td>[abc]</td>
<td>die Kleinbuchstaben &#8220;a&#8221;, &#8220;b&#8221; und &#8220;c&#8221;</td>
</tr>
<tr>
<td>[a-zA-Z]</td>
<td>ein einzelner Buchstabe</td>
</tr>
<tr>
<td>[^a-z]</td>
<td>Sucht nach einem beliebigen Zeichen, welches kein Kleinbuchstabe ist.</td>
</tr>
<tr>
<td>[0-9]</td>
<td>eine einzelne Zahl</td>
</tr>
<tr>
<td>[0-4a-d]+</td>
<td>jede Zahl zwischen &#8220;0&#8243; und &#8220;4&#8243; und jeden Kleinbuchstaben zwischen &#8220;a&#8221; und &#8220;d&#8221;</td>
</tr>
<tr>
<td>(hallo|welt)</td>
<td>die Wörter &#8220;hallo&#8221; und &#8220;welt&#8221;</td>
</tr>
<tr>
<td>[a-z]{3,5}</td>
<td>mindestens drei und maximal fünf Kleinbuchstaben zwischen &#8220;a&#8221; und &#8220;z&#8221;</td>
</tr>
</table>
<p>Und jetzt einige Praxisbeispiel:</p>
<h4>Den Inhalt der H1 Überschrift einer Webseite ermitteln</h4>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$html</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;h1&gt;PHP REGEX&lt;/h1&gt;&lt;h2&gt;Beispiel&lt;/h2&gt;&lt;/body&gt;&lt;/html&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'~&lt;h1&gt;(.+?)&lt;/h1&gt;~is'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$html</span><span style="color: #339933;">,</span> <span style="color: #000088;">$matches</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$matches</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h4>Den Inhalt aller Überschrift einer Webseite ermitteln</h4>
<p>Der Inhalt der Überschriften befindet sich in $matches[2].</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$html</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;h1&gt;PHP REGEX&lt;/h1&gt;&lt;h2&gt;Beispiel&lt;/h2&gt;&lt;/body&gt;&lt;/html&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">preg_match_all</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'~&lt;h([1-6])&gt;(.+?)&lt;/h\1&gt;~is'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$html</span><span style="color: #339933;">,</span> <span style="color: #000088;">$matches</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">var_dump</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$matches</span><span style="color: #009900;">&#41;</span></pre></td></tr></table></div>

<h4>Telefonnummer prüfen</h4>
<p>Hier wird nur geprüft ob es sich um eine Zahlenfolge handelt. Ein Plus vor der Telefonnummer ist optional.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$nummer</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;+4937512345678&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/^[+]?[0-9]+$/'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$nummer</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;korrekt!&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: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;nicht korrekt!&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<h4>Wiederholende Leerzeichen ersetzen </h4>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$text</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;PHP REGEX         Test Text.&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$text</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/[ ]{2,}/&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$text</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$text</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h4>IP Adresse prüfen</h4>
<p>Eine IP Adresse besteht aus vier Blöcken, welche jeweils mit einem Punkt voneinander getrennt sind. Jeder einzelne Block kann im Bereich von 0 &#8211; 255 liegen. Mal abgesehen von einigen speziellen Adressen, welche ich nicht berücksichtigt habe, prüft folgendes Regex eine IP Adresse auf Gültigkeit. Spezielle Adresse sind z.B. Broadcast, Zeroconf, Anycast oder Multicast.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$ip</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;192.168.12.203&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/^(([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\.){3}([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])$/'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$ip</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;korrekt!&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: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;nicht korrekt!&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<h4>Datumsangaben aus ein Text filtern</h4>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$text</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Was war noch gleich am 24.12.2010 und was am 1.1.99&quot;</span><span style="color: #339933;">;</span>  
<span style="color: #990000;">preg_match_all</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/([012]?[0-9]|3[01])\.(0?[0-9]|1[0-2])\.(([12][0-9])?[0-9][0-9])/'</span><span style="color: #339933;">,</span><span style="color: #000088;">$text</span><span style="color: #339933;">,</span> <span style="color: #000088;">$matches</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">var_dump</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$matches</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.tsql.de/php/php_preg_regex_regulaerer_ausdruck/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C# Hashfunktion MD5 und SHA1</title>
		<link>http://www.tsql.de/csharp/csharp_md5_sha1_hash</link>
		<comments>http://www.tsql.de/csharp/csharp_md5_sha1_hash#comments</comments>
		<pubDate>Sun, 13 Feb 2011 13:42:32 +0000</pubDate>
		<dc:creator>Michael Klaus</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[md5]]></category>
		<category><![CDATA[sha1]]></category>
		<category><![CDATA[System.Security.Cryptography]]></category>

		<guid isPermaLink="false">http://www.tsql.de/?p=1741</guid>
		<description><![CDATA[C# MD5 Hash und SHA1 Hash berechnen.]]></description>
				<content:encoded><![CDATA[<p>Zur Berechnung des MD5 und des SHA1 Hashes in C# bedient man sich des &#8220;System.Security.Cryptography&#8221; Namespaces.</p>
<p>Quellcode C# MD5:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
<span style="color: #008080; font-style: italic;">/// Liefert den MD5 Hash </span>
<span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
<span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;input&quot;&gt;Eingabestring&lt;/param&gt;</span>
<span style="color: #008080; font-style: italic;">/// &lt;returns&gt;MD5 Hash der Eingabestrings&lt;/returns&gt;</span>
<span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">string</span> getMD5<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> input<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    <span style="color: #008080; font-style: italic;">//Umwandlung des Eingastring in den MD5 Hash</span>
    <span style="color: #000000;">System.<span style="color: #0000FF;">Security</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Cryptography</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">MD5</span> md5 <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> <span style="color: #000000;">System.<span style="color: #0000FF;">Security</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Cryptography</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">MD5CryptoServiceProvider</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #6666cc; font-weight: bold;">byte</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> textToHash <span style="color: #008000;">=</span> Encoding<span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Default</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GetBytes</span><span style="color: #008000;">&#40;</span>input<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #6666cc; font-weight: bold;">byte</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> result <span style="color: #008000;">=</span> md5<span style="color: #008000;">.</span><span style="color: #0000FF;">ComputeHash</span><span style="color: #008000;">&#40;</span>textToHash<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">//MD5 Hash in String konvertieren</span>
    <span style="color: #000000;">System.<span style="color: #0000FF;">Text</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">StringBuilder</span> s <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> <span style="color: #000000;">System.<span style="color: #0000FF;">Text</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">StringBuilder</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #0600FF; font-weight: bold;">foreach</span> <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">byte</span> b <span style="color: #0600FF; font-weight: bold;">in</span> result<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        s<span style="color: #008000;">.</span><span style="color: #0000FF;">Append</span><span style="color: #008000;">&#40;</span>b<span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;x2&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ToLower</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">return</span> s<span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>Quellcode C# SHA1:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
<span style="color: #008080; font-style: italic;">/// Liefert den SHA1 Hash </span>
<span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
<span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;input&quot;&gt;Eingabestring&lt;/param&gt;</span>
<span style="color: #008080; font-style: italic;">/// &lt;returns&gt;SHA1 Hash der Eingabestrings&lt;/returns&gt;</span>
<span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">string</span> getSHA1<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> input<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    <span style="color: #008080; font-style: italic;">//Umwandlung des Eingastring in den SHA1 Hash</span>
    <span style="color: #000000;">System.<span style="color: #0000FF;">Security</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Cryptography</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">SHA1</span> sha1 <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> <span style="color: #000000;">System.<span style="color: #0000FF;">Security</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Cryptography</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">SHA1CryptoServiceProvider</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #6666cc; font-weight: bold;">byte</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> textToHash <span style="color: #008000;">=</span> Encoding<span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Default</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GetBytes</span><span style="color: #008000;">&#40;</span>input<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #6666cc; font-weight: bold;">byte</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> result <span style="color: #008000;">=</span> sha1<span style="color: #008000;">.</span><span style="color: #0000FF;">ComputeHash</span><span style="color: #008000;">&#40;</span>textToHash<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">//SHA1 Hash in String konvertieren</span>
    <span style="color: #000000;">System.<span style="color: #0000FF;">Text</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">StringBuilder</span> s <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> <span style="color: #000000;">System.<span style="color: #0000FF;">Text</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">StringBuilder</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #0600FF; font-weight: bold;">foreach</span> <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">byte</span> b <span style="color: #0600FF; font-weight: bold;">in</span> result<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        s<span style="color: #008000;">.</span><span style="color: #0000FF;">Append</span><span style="color: #008000;">&#40;</span>b<span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;x2&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ToLower</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">return</span> s<span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>Grundlegend sind die beiden Methoden gleich.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tsql.de/csharp/csharp_md5_sha1_hash/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Switch</title>
		<link>http://www.tsql.de/php/php_switch_case</link>
		<comments>http://www.tsql.de/php/php_switch_case#comments</comments>
		<pubDate>Fri, 11 Feb 2011 19:32:13 +0000</pubDate>
		<dc:creator>Michael Klaus</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[switch]]></category>

		<guid isPermaLink="false">http://www.tsql.de/?p=1732</guid>
		<description><![CDATA[PHP switch case Anweisung. Beispiele für die Verwendung. Fallunterscheidung in PHP mit switch, case und default.]]></description>
				<content:encoded><![CDATA[<p>Zur Fallunterscheidung in PHP bietet sich die &#8220;switch case&#8221; Anweisung geradezu an.  Zu beachten ist bei PHP, dass die einzelnen Cases, also die Fälle mit einem break abgeschlossen werden müssen. Ist das break nicht vorhanden werden alle weiteren Cases bis zum nächsten break auch mit ausgeführt. Dieses Verhalten kann von Vorteil sein, man muss es nur kennen.<br />
Sollte kein Fall zutreffen wird wenn vorhanden der default-case abgearbeitet.<br />
&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">	<span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;A&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">switch</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">case</span> <span style="color: #0000ff;">&quot;A&quot;</span><span style="color: #339933;">:</span>
			<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Fall A&quot;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">case</span> <span style="color: #0000ff;">&quot;B&quot;</span><span style="color: #339933;">:</span>
			<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Fall B&quot;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">default</span><span style="color: #339933;">:</span>
			<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Standard Fall&quot;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Wenn der selbe Code für mehrere Fälle gültig ist, muss das break Schlüsselwort fehlen.<br />
&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">	<span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;B&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">switch</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">case</span> <span style="color: #0000ff;">&quot;A&quot;</span><span style="color: #339933;">:</span>
		<span style="color: #b1b100;">case</span> <span style="color: #0000ff;">&quot;B&quot;</span><span style="color: #339933;">:</span>
		<span style="color: #b1b100;">case</span> <span style="color: #0000ff;">&quot;C&quot;</span><span style="color: #339933;">:</span>
			<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Fall A-C&quot;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">case</span> <span style="color: #0000ff;">&quot;D&quot;</span><span style="color: #339933;">:</span>
			<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Fall D&quot;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">default</span><span style="color: #339933;">:</span>
			<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Standard Fall&quot;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.tsql.de/php/php_switch_case/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Array zufällig sortieren</title>
		<link>http://www.tsql.de/php/php_array_shuffle_sortieren_zufall</link>
		<comments>http://www.tsql.de/php/php_array_shuffle_sortieren_zufall#comments</comments>
		<pubDate>Fri, 11 Feb 2011 16:57:36 +0000</pubDate>
		<dc:creator>Michael Klaus</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[zufall]]></category>

		<guid isPermaLink="false">http://www.tsql.de/?p=1725</guid>
		<description><![CDATA[Die Reihenfolge aller Elemente eines Arrays zufällig neu sortieren und anschließend ausgeben.]]></description>
				<content:encoded><![CDATA[<p>Die Reihenfolge aller Elemente eines Arrays zufällig neu sortieren und anschließend ausgeben. Hier ist die Lösung:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
	<span style="color: #666666; font-style: italic;">//dem Zufall auf die Sprünge helfen</span>
	<span style="color: #990000;">srand</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>float<span style="color: #009900;">&#41;</span><span style="color: #990000;">microtime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">1000000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//array anlegen</span>
	<span style="color: #000088;">$karten</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Bube'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Dame'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'König'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//zufällig michen</span>
	<span style="color: #990000;">shuffle</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$karten</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//array ausgeben</span>
	<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$karten</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$karte</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$karte</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;br /&gt;'</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.tsql.de/php/php_array_shuffle_sortieren_zufall/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C# INI File lesen</title>
		<link>http://www.tsql.de/csharp/csharp-ini-file-lesen</link>
		<comments>http://www.tsql.de/csharp/csharp-ini-file-lesen#comments</comments>
		<pubDate>Fri, 19 Nov 2010 16:32:47 +0000</pubDate>
		<dc:creator>Michael Klaus</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[ini]]></category>

		<guid isPermaLink="false">http://www.tsql.de/?p=1702</guid>
		<description><![CDATA[Auslesen einer INI-Datei mit CSharp.]]></description>
				<content:encoded><![CDATA[<p>In diesem Beispiel wird das Auslesen einer INI-Datei gezeigt. Hier erst mal der Inhalt der INI-Datei:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="ini" style="font-family:monospace;"><span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>Option<span style="">&#93;</span></span>
<span style="color: #000099;">Farbe</span><span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">blau</span>
<span style="color: #000099;">Name</span><span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">Hans</span></pre></td></tr></table></div>

<p>Der Quellcode:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Runtime.InteropServices</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.IO</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #008000;">&#91;</span>DllImport<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;kernel32&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#93;</span>
<span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #0600FF; font-weight: bold;">extern</span> <span style="color: #6666cc; font-weight: bold;">int</span> GetPrivateProfileString<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> section,
<span style="color: #6666cc; font-weight: bold;">string</span> key, <span style="color: #6666cc; font-weight: bold;">string</span> def, StringBuilder retVal, <span style="color: #6666cc; font-weight: bold;">int</span> size, <span style="color: #6666cc; font-weight: bold;">string</span> filePath<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> GetString<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> section, <span style="color: #6666cc; font-weight: bold;">string</span> key<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
<span style="color: #0600FF; font-weight: bold;">const</span> <span style="color: #6666cc; font-weight: bold;">int</span> size <span style="color: #008000;">=</span> <span style="color: #FF0000;">255</span><span style="color: #008000;">;</span>
      <span style="color: #6666cc; font-weight: bold;">string</span> file <span style="color: #008000;">=</span> Environment<span style="color: #008000;">.</span><span style="color: #0000FF;">CurrentDirectory</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;<span style="color: #008080; font-weight: bold;">\\</span>test.INI&quot;</span><span style="color: #008000;">;</span>
      <span style="color: #6666cc; font-weight: bold;">string</span> def <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;&quot;</span><span style="color: #008000;">;</span>
&nbsp;
      StringBuilder sb <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> StringBuilder<span style="color: #008000;">&#40;</span>size<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
      GetPrivateProfileString<span style="color: #008000;">&#40;</span>section, key, def, sb, size, file<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
      <span style="color: #0600FF; font-weight: bold;">return</span> sb<span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>Auslesen des Schlüssels &#8220;Farbe&#8221; aus der Sektion &#8220;Options&#8221;:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> args<span style="color: #008000;">;</span>
args <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> <span style="color: #008000;">&#123;</span>GetString<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Options&quot;</span>, <span style="color: #666666;">&quot;Farbe&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#125;</span><span style="color: #008000;">;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.tsql.de/csharp/csharp-ini-file-lesen/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
