Hello guys im sorry but i am newbie to php, in my site i have multiple language with GET.. Example site.com/index.php?lang=en to the nav menu i have a code like this
<?php
$url = $_SERVER[REQUEST_URI];
$query = parse_url($url, PHP_URL_QUERY);
// Returns a string if the URL has parameters or NULL if not
if ($query) {
$url .= '&lang=';
} else {
$url .= '?lang=';
}
?>
<li><a href="<?php echo $url;?>en">
My problem is when the lang is set. Example site.com/index.php?lang=en when the user change the lang adds the lang to site.com/index.php?lang=en&lang=gr .
I want to "replace" the lang and not have a url like site.com/index.php?lang=gr&lang=en&lang=en&lang=en&lang=en
thank you guys
$_GETit would be simpler and you woudl not cause the multipe parameter issue