This is my function, I simply want to output a link like this:
www.example.com/new?cat=22,23,27
If a category value already exists I want to delete it. If it doesn't exist yet, i want to add it.
This is my function:
function setorunset($value) {
if(isset($_GET['cat'])) { //wenn schon eine categorie da ist
if(strpos($value,$_GET['cat']) === false ) {
$_GET['cat'] .= ",".$value; }
else {
str_replace(",".$value, ",", $_GET['cat']);
}
echo http_build_query($_GET);
}
else {
echo http_build_query($_GET).'&cat='.$value;
}
}
I simply can't find the error why this shouldnt work: I call this function with: setorunset(22);
Does anyone find any error?