Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/231.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在php中重建url_Php - Fatal编程技术网

在php中重建url

在php中重建url,php,Php,我有这个网址:https://www.example.net/demo/index.php?order&bank&success&ho?TPE=monet14&date=12%2f07%2f2018_a_11%3a32%3a28&montant=53EUR 我必须通过ho&TPE在change ho?TPE中重建此url 我要这样做: $query = $_GET; // replace parameter(s) $query['?'] = '&'; // reb

我有这个网址:https://www.example.net/demo/index.php?order&bank&success&ho?TPE=monet14&date=12%2f07%2f2018_a_11%3a32%3a28&montant=53EUR

我必须通过ho&TPE在change ho?TPE中重建此url

我要这样做:

      $query = $_GET;
// replace parameter(s)
      $query['?'] = '&';
// rebuild url
      $query_result = http_build_query($query);
bu结果是:&ho%3FTPE

如何在中更改%3F&

我的最后一个问题是,我必须在最后的结果中回答这个问题

array(24) { ["order"]=> string(0) "" ["desjardins"]=> string(0) "" ["success"]=> string(0) "" ["ho"]=> string(0) "" ["TPE"]=> string(7) "monet14"

感谢您使用php explode函数:

explode("&", $theurl);
您可以从那里操纵阵列,然后简单地将其内爆返回到所需的结果:

[连结]

[链接]

在这种情况下,用户可以尝试解析url

$url = 'https://www.example.net/demo/index.php?order&bank&success&ho?TPE=monet14&date=12%2f07%2f2018_a_11%3a32%3a28&montant=53EUR';
$parsed = parse_url($url);
$parsed['query']  = str_replace('?', '&', $parsed['query']);
$url = implode('', $parsed);

URL是如何构建的?可能重复的不重复多次发布同一问题。如果您需要澄清某些内容,请单击问题下方的“编辑”按钮,或在您的问题或其中一个答案下方添加注释。@mike该url由银行创建。我只发送这个元素:更改URL有什么意义?通过这样做,您解决了什么实际问题?您不能在那里使用内爆,因为它遗漏了url方案://,它可能遗漏了用户名密码:,它将遗漏?在查询中,以及在片段中
explode("&", $theurl);
$url = 'https://www.example.net/demo/index.php?order&bank&success&ho?TPE=monet14&date=12%2f07%2f2018_a_11%3a32%3a28&montant=53EUR';
$parsed = parse_url($url);
$parsed['query']  = str_replace('?', '&', $parsed['query']);
$url = implode('', $parsed);