<?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>nessio.de &#124; Bennis Blog &#187; zufallszahlen</title>
	<atom:link href="http://nessio.de/tag/zufallszahlen/feed/" rel="self" type="application/rss+xml" />
	<link>http://nessio.de</link>
	<description>Rund ums Web - Development, Webseiten, Tools, Apps, Tipps &#38; Tricks</description>
	<lastBuildDate>Thu, 05 Jan 2012 10:37:39 +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>Ungleiche Zufallszahlen mit PHP generieren</title>
		<link>http://nessio.de/2009/10/22/ungleiche-zufallszahlen-mit-php-generieren/</link>
		<comments>http://nessio.de/2009/10/22/ungleiche-zufallszahlen-mit-php-generieren/#comments</comments>
		<pubDate>Thu, 22 Oct 2009 15:25:41 +0000</pubDate>
		<dc:creator>Benni</dc:creator>
				<category><![CDATA[Dev / Codeschnipsel]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[zahlen]]></category>
		<category><![CDATA[zufall]]></category>
		<category><![CDATA[zufallszahlen]]></category>

		<guid isPermaLink="false">http://blog.nessio.net/?p=224</guid>
		<description><![CDATA[Zu diesem Thema findet man leider recht wenig Informationen im Internet, wozu ich mich entschlossen habe einen Codeschnipsel zu veröffentlichen der unterschiedliche Zufallszahlen in PHP generiert. Folgende Funktion kann für die Generierung verwendet werden: 1 2 3 4 5 6 7 8 9 10 11 function generate_numbers&#40; $min, $max, $anz &#41; &#123; $array = range&#40; [...]]]></description>
			<content:encoded><![CDATA[<p>Zu diesem Thema findet man leider recht wenig Informationen im Internet, wozu ich mich entschlossen habe einen Codeschnipsel zu veröffentlichen der unterschiedliche Zufallszahlen in PHP generiert.</p>
<p>Folgende Funktion kann für die Generierung verwendet werden:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> generate_numbers<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$min</span><span style="color: #339933;">,</span> <span style="color: #000088;">$max</span><span style="color: #339933;">,</span> <span style="color: #000088;">$anz</span> <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$array</span> <span style="color: #339933;">=</span> <span style="color: #990000;">range</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$min</span><span style="color: #339933;">,</span> <span style="color: #000088;">$max</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">srand</span><span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span>double<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>
    <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$x</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$x</span><span style="color: #339933;">&lt;</span><span style="color: #000088;">$anz</span><span style="color: #339933;">;</span> <span style="color: #000088;">$x</span><span style="color: #339933;">++</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #990000;">rand</span><span style="color: #009900;">&#40;</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$array</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$erg</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$array</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
        <span style="color: #990000;">array_splice</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$array</span><span style="color: #339933;">,</span> <span style="color: #000088;">$i</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</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: #000088;">$erg</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Diese Funktion wird mit den Werten &#8220;von welcher Zahl&#8221;, &#8220;bis zu welcher Zahl&#8221; &#038; &#8220;wieviele Zahlen&#8221; aufgerufen.<br />
Beispiel:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$zufalls_array</span> <span style="color: #339933;">=</span> generate_numbers<span style="color: #009900;">&#40;</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Das Beispiel generiert zwei ungleiche Zufallszahlen zwischen 1 &#038; 10 und gibt diese aus.</p>
]]></content:encoded>
			<wfw:commentRss>http://nessio.de/2009/10/22/ungleiche-zufallszahlen-mit-php-generieren/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

