Possible Duplicate:
Replace values in a URI query string
I am using a language switcher in the navigation bar to switch between EN and DE, my url structure is like this:
http://www.mydomain.com/gallery.php?lang=de
http://www.mydomain.com/gallery-item.php?id=100&lang=de
The switch works well on all urls which don't have an id, but it doesn't work with the ids.
<?php
$url="http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
<a href='.$url.'?lang=en">
<a href='.$url.'?lang=de">
?>
What is a good solution to check for $lang=xx or ?lang=xx and then add ?lang=xx or $lang=xx respectively?
?only, if$_SERVER['PHP_SELF']is not set (this variable contains the url parameters) and add an&if it is set. :)