php else echo if no match
<p>I have an array that I'm trying alter the output if a particular string is found.  </p>

<p>As you can see below it successfully changes Upper Captiva to Captiva when the condition occurs but my else statement is ignored where it should simply show the $row['SUBDIVISION'] value if the condition does not occur.  </p>

<p>I've tried adding $mycodes and $row['SUBDIVISION'] to the else line with no luck.  </p>

<pre><code>&lt;?php
    $mycodes = explode(",", $row['SUBDIVISION']);
    $arr = array(   "Upper Captiva" =&gt; "Captiva",);
    $printedsomething=0;
    foreach($mycodes as $code) {
        if ($arr[$code] != '' ) {
            if ($printedsomething==1)  echo ", " . $arr[$code];
            else echo $mycodes;
            $printedsomething=1;
        }
    }  //end for loop
?&gt;
</code></pre>
