 <p>The reason for the result you see is the comparison operator you use. == is too imprecise sometimes and can result in wierd things like this. Using the === will compare the values for exactness and will prevent the issue you have.</p> <p>so: </p> <pre><code>foreach ($arr as $k=&gt;$v) { // this is the important thing if ($k === "thispage") { echo $k." "; } else { echo '&lt;a href="'.$v.'"&gt;'.$k.'&lt;/a&gt; '; } } </code></pre>