PHP array iteration with key value pair
<p>I want to iterate through an array with "$key => $value" pair but want to go up to the last but one item. I want to know how that is doable using foreach or any other function.</p>

<p>Here is why I want to do it.
The key in my array is the URL parameter and the value is the value of that parameter. Now I will be constructing the URL query as 
key1=value1&amp;key2=value2&amp;key3=value3</p>

<p>I will add the delimiter "&amp;" in between each key-value but not at the end. To do that I wanted to go up to the last but one item by putting the delimiter and change the last one's delimiter to be blank string.</p>

<p>So please let me know how foreach can be used to go up to last but one item or get me a better solution? Thanks.</p>
