Reputation: 59
<?php
$test = 'marke=' . $_GET["marke"] . '&farbe=' . $_GET["farbe"]. '&groesse=' . $_GET["groesse"];
?>
<?php
echo $test;
?>
echo would be: marke=diesel&farbe=blau&groesse=xl
How can i remove &farbe=blau from $test ?
Upvotes: 0
Views: 53
Reputation: 2136
Have you tried using a regular expression with preg_replace()
? Off the top of my head, try something like:
preg_replace('/&farbe=.+?&/','',$test);
Upvotes: 0
Reputation: 70540
Use parse_str
and http_build_query
to reliably parse and create query-strings (which also takes care of nasty url-encoding issues):
// You could probably have created $test with:
// $test = http_build_query($_GET);
parse_str($test,$values);
unset($values['farbe']);
$test = http_build_query($values);
Upvotes: 1