This takes an associative array and returns a string like key1=val1&key2=val2.
<?php function httpimplode($aryInput, $pre = '', $aft = '') { if (!empty($pre)) { $result = $pre; } else { $result = ''; } if (is_array($aryInput) && count($aryInput)>0) { foreach ($aryInput as $key=>$value) { if (strlen($result)>1) { $result .= '&'; } $result .= urlencode($key) . '=' . urlencode($value); } if (!empty($aft)) { $result .= $aft; } } return $result; } $params['lang'] = 'de'; echo 'http://www.blabla.com' . httpimplode($params, '?', ''); echo 'http://www.blabla.com' . httpimplode($params, '?', '&') . 'show=all'; ?>