<?php
$test = 'marke=' . $_GET["marke"] . '&farbe=' . $_GET["farbe"]. '&groesse=' . $_GET["groesse"];
?>
<?php
echo $test;
?>
回音是:坊间=柴油& FARBE =布劳& groesse = XL删除部分
如何从$测试中去掉& FARBE =布劳?
<?php
$test = 'marke=' . $_GET["marke"] . '&farbe=' . $_GET["farbe"]. '&groesse=' . $_GET["groesse"];
?>
<?php
echo $test;
?>
回音是:坊间=柴油& FARBE =布劳& groesse = XL删除部分
如何从$测试中去掉& FARBE =布劳?
使用parse_str
和http_build_query
可靠地解析和创建查询字符串(这也需要讨厌的URL编码问题护理):
// You could probably have created $test with:
// $test = http_build_query($_GET);
parse_str($test,$values);
unset($values['farbe']);
$test = http_build_query($values);
完美的谢谢! –
您是否尝试过使用a regular expression with preg_replace()
?关闭我的头顶,尝试类似于:
preg_replace('/&farbe=.+?&/','',$test);
不错,也可以,但我只能检查一个答案^^ –
完全没有问题 - 无论哪个人更好,更快,更多的文档回答你的问题,等等。毕竟,很少有一种方法可以做到。 – Mike
如何在不首先添加它?摆脱'&farbe ='。 $ _GET [ 'FARBE']。 ''部分 –
这将是太多的工作,超过5个参数 –