unset() from array versus if inside loop?
<p>I'm making a pagination script. As part of it, it will need to reconstruct the query string, minus <code>$_GET['page']</code>.</p>

<p>This is option 1:</p>

<pre><code>#reconstruct the GETs minus $_GET['page']
$vars = $_GET;
unset($vars['page']);
$queryString = '';
foreach ($vars as $k=&gt;$v){
    $queryString .= '&amp;amp;'.$k.'='.$v;
}
</code></pre>

<p>This is option 2:</p>

<pre><code>$vars = $_GET;
$queryString = '';
foreach ($vars as $k=&gt;$v){
    if ($k !== 'page'){
        $queryString .= '&amp;amp;'.$k.'='.$v;
    }
}
</code></pre>

<p>Is one better than the other in terms of either speed or good practice? Presumably <code>unset</code> would be marginally quicker, as it would stop as soon as it found what it was looking for whereas the other would perform the <code>if</code> for every loop?</p>

<p>Additionally, when initializing the <code>$queryString</code> is there a reason to choose <code>NULL</code> over empty string or does it make no difference to anything?</p>
