<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: FizzBuzz in PHP</title>
	<atom:link href="http://kevinfrancis.net/journal/2007/04/fizzbuzz-in-php/feed/" rel="self" type="application/rss+xml" />
	<link>http://kevinfrancis.net/journal/2007/04/fizzbuzz-in-php/</link>
	<description>the occasional journal of kevin francis</description>
	<pubDate>Tue, 06 Jan 2009 04:13:57 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.5</generator>
		<item>
		<title>By: Jeremy Coleman</title>
		<link>http://kevinfrancis.net/journal/2007/04/fizzbuzz-in-php/#comment-139</link>
		<dc:creator>Jeremy Coleman</dc:creator>
		<pubDate>Mon, 04 Jun 2007 04:42:18 +0000</pubDate>
		<guid isPermaLink="false">http://inactiva.org/journal/2007/04/12/fizzbuzz-in-php/#comment-139</guid>
		<description>&lt;p&gt;I found this post randomly googling some PHP issue and thought I would put my spin on it.  I consider myself a below entry level programmer, it's a hobby that I hope to someday turn into a job.  Anyway, here's my convoluted solution.&lt;/p&gt;

&lt;p&gt;$c = "Fizz";
$d = "Buzz";
$e = "n";&lt;/p&gt;

&lt;p&gt;for($i=1;$i&#60;=100;$i++){
$a = $i%3;
$b = $i%5;
    if(!$a){
        if(!$b){
            echo $c.$d.$e;
        }else{
            echo $c.$e;
        }
    }elseif(!$b){
        echo $d.$e;
    }else{
        echo $i.$e;
    }
}&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I found this post randomly googling some PHP issue and thought I would put my spin on it.  I consider myself a below entry level programmer, it&#8217;s a hobby that I hope to someday turn into a job.  Anyway, here&#8217;s my convoluted solution.</p>

<p>$c = &#8220;Fizz&#8221;;
$d = &#8220;Buzz&#8221;;
$e = &#8220;n&#8221;;</p>

<p>for($i=1;$i&lt;=100;$i++){
$a = $i%3;
$b = $i%5;
    if(!$a){
        if(!$b){
            echo $c.$d.$e;
        }else{
            echo $c.$e;
        }
    }elseif(!$b){
        echo $d.$e;
    }else{
        echo $i.$e;
    }
}</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Kevin Francis</title>
		<link>http://kevinfrancis.net/journal/2007/04/fizzbuzz-in-php/#comment-144</link>
		<dc:creator>Kevin Francis</dc:creator>
		<pubDate>Wed, 09 May 2007 13:04:32 +0000</pubDate>
		<guid isPermaLink="false">http://inactiva.org/journal/2007/04/12/fizzbuzz-in-php/#comment-144</guid>
		<description>&lt;p&gt;Wow Jyrki that certainly is a very umm compact answer :P&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Wow Jyrki that certainly is a very umm compact answer :P</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Jyrki</title>
		<link>http://kevinfrancis.net/journal/2007/04/fizzbuzz-in-php/#comment-143</link>
		<dc:creator>Jyrki</dc:creator>
		<pubDate>Wed, 09 May 2007 07:41:07 +0000</pubDate>
		<guid isPermaLink="false">http://inactiva.org/journal/2007/04/12/fizzbuzz-in-php/#comment-143</guid>
		<description>&lt;p&gt;How about 75 bytes? Geeky enough? :)&lt;/p&gt;

&lt;p&gt;for($i=1;$i&#60;101;$i++)echo $i%15?$i%5?$i%3?$i:'Fizz':'Buzz':'FizzBuzz',"\n";&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>How about 75 bytes? Geeky enough? :)</p>

<p>for($i=1;$i&lt;101;$i++)echo $i%15?$i%5?$i%3?$i:&#8217;Fizz&#8217;:'Buzz&#8217;:'FizzBuzz&#8217;,&#8221;\n&#8221;;</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Gauthier</title>
		<link>http://kevinfrancis.net/journal/2007/04/fizzbuzz-in-php/#comment-138</link>
		<dc:creator>Gauthier</dc:creator>
		<pubDate>Wed, 02 May 2007 16:49:49 +0000</pubDate>
		<guid isPermaLink="false">http://inactiva.org/journal/2007/04/12/fizzbuzz-in-php/#comment-138</guid>
		<description>&lt;p&gt;I really liked this but, &lt;/p&gt;

&lt;p&gt;for ($num=1; $num&#60;=100; $num++) {
        if ($num%3 == 0) {
                echo "Fizz"; $keepNum = true;
        }
        if ($num%5 == 0) {
                echo "Buzz"; $keepNum = true;
        }
        if (!$keepNum) {
                echo $num;
        }
        $keepNum = false;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;    echo "&#60;br /&#62;";
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;} &lt;/p&gt;

&lt;p&gt;I really like yours Ken, I cleaned it up a bit ;-)&lt;/p&gt;

&lt;p&gt;foreach (range(1,100) as $num) {
    $msg ='';
    if ($num%3 == 0) $msg = "Fizz";
    if ($num%5 == 0) $msg .= "Buzz";
    if (!$msg)   $msg = $num;
    print "$msg\n";
}&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I really liked this but, </p>

<p>for ($num=1; $num&lt;=100; $num++) {
        if ($num%3 == 0) {
                echo &#8220;Fizz&#8221;; $keepNum = true;
        }
        if ($num%5 == 0) {
                echo &#8220;Buzz&#8221;; $keepNum = true;
        }
        if (!$keepNum) {
                echo $num;
        }
        $keepNum = false;</p>

<pre><code>    echo "&lt;br /&gt;";
</code></pre>

<p>} </p>

<p>I really like yours Ken, I cleaned it up a bit ;-)</p>

<p>foreach (range(1,100) as $num) {
    $msg =&#8221;;
    if ($num%3 == 0) $msg = &#8220;Fizz&#8221;;
    if ($num%5 == 0) $msg .= &#8220;Buzz&#8221;;
    if (!$msg)   $msg = $num;
    print &#8220;$msg\n&#8221;;
}</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Ken Brush</title>
		<link>http://kevinfrancis.net/journal/2007/04/fizzbuzz-in-php/#comment-137</link>
		<dc:creator>Ken Brush</dc:creator>
		<pubDate>Thu, 19 Apr 2007 16:56:46 +0000</pubDate>
		<guid isPermaLink="false">http://inactiva.org/journal/2007/04/12/fizzbuzz-in-php/#comment-137</guid>
		<description>&lt;p&gt;Heh, noticed you changed the conditional in the main article now.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Heh, noticed you changed the conditional in the main article now.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Ken Brush</title>
		<link>http://kevinfrancis.net/journal/2007/04/fizzbuzz-in-php/#comment-136</link>
		<dc:creator>Ken Brush</dc:creator>
		<pubDate>Thu, 12 Apr 2007 16:44:58 +0000</pubDate>
		<guid isPermaLink="false">http://inactiva.org/journal/2007/04/12/fizzbuzz-in-php/#comment-136</guid>
		<description>&lt;p&gt;I like how the conditional doesn't print Buzz, even though that's a requirement. &lt;/p&gt;

&lt;p&gt;wouldn't this work better:&lt;/p&gt;

&lt;p&gt;foreach (range(1,100) as $number) {
       $msg='';
       if ( $number%3 == 0) {
           $msg .= "Fizz";
       }
       if ($number%5 == 0) {
           $msg .= "Buzz";
       }
       if (empty($msg)) {
            $msg = $number;
       }
       print "$msg\n";
}&lt;/p&gt;

&lt;p&gt;Of course, being the conditional lover I am, I would probably write the last  if (the empty check) to this:&lt;/p&gt;

&lt;p&gt;foreach (range(1,100) as $number) {
       $msg='';
       if ( $number%3 == 0) {
           $msg .= "Fizz";
       }
       if ($number%5 == 0) {
           $msg .= "Buzz";
       }
       printf ("%s\n", (empty($msg) ? $number : $msg));
}&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I like how the conditional doesn&#8217;t print Buzz, even though that&#8217;s a requirement. </p>

<p>wouldn&#8217;t this work better:</p>

<p>foreach (range(1,100) as $number) {
       $msg=&#8221;;
       if ( $number%3 == 0) {
           $msg .= &#8220;Fizz&#8221;;
       }
       if ($number%5 == 0) {
           $msg .= &#8220;Buzz&#8221;;
       }
       if (empty($msg)) {
            $msg = $number;
       }
       print &#8220;$msg\n&#8221;;
}</p>

<p>Of course, being the conditional lover I am, I would probably write the last  if (the empty check) to this:</p>

<p>foreach (range(1,100) as $number) {
       $msg=&#8221;;
       if ( $number%3 == 0) {
           $msg .= &#8220;Fizz&#8221;;
       }
       if ($number%5 == 0) {
           $msg .= &#8220;Buzz&#8221;;
       }
       printf (&#8221;%s\n&#8221;, (empty($msg) ? $number : $msg));
}</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Kevin Francis</title>
		<link>http://kevinfrancis.net/journal/2007/04/fizzbuzz-in-php/#comment-135</link>
		<dc:creator>Kevin Francis</dc:creator>
		<pubDate>Thu, 12 Apr 2007 16:16:24 +0000</pubDate>
		<guid isPermaLink="false">http://inactiva.org/journal/2007/04/12/fizzbuzz-in-php/#comment-135</guid>
		<description>&lt;p&gt;Well, the second approach is overkill really, and uses extra processing power. The first and last examples are the most efficient really when it comes to readability and processing.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Well, the second approach is overkill really, and uses extra processing power. The first and last examples are the most efficient really when it comes to readability and processing.</p>]]></content:encoded>
	</item>
</channel>
</rss>
