首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >重建url n php

重建url n php
EN

Stack Overflow用户
提问于 2018-08-16 08:08:43
回答 2查看 292关注 0票数 -3

我有一个网址: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更改ho?TPE )中重新构建此url

https://www.example.net/demo/index.php?order&desjardins&success&ho&TPE=monet14&date=12%2f07%2f2018_a_11%3a32%3a28&montant=53EUR

我这样做:

      $query = $_GET;
// replace parameter(s)
      $query['?'] = '&';
// rebuild url
      $query_result = http_build_query($query);

但结果是:(&ho%3FTPE)

order=&desjardins=&success=&ho%3FTPE=monet14&date=12%2F07%2F2018_a_11%3A32%3A28&montant=53EUR

如何在&中更改%3F

我的最后一个问题,我必须在最终结果中得到这个。

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

谢谢

EN

回答 2

Stack Overflow用户

发布于 2018-08-16 08:31:06

使用php "explode“函数:

explode("&", $theurl);

您可以从那里操作数组,并简单地将其“内爆”回您想要的结果:

link

link

票数 0
EN

Stack Overflow用户

发布于 2018-08-16 09:10:38

在这种情况下,用户可以尝试使用parse_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);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51867996

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档