Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
419 views
in Technique[技术] by (71.8m points)

Rebuild url n php

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

and I must rebuild this url in (change ho?TPE by ho&TPE)

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

I make this :

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

bu the result is : (&ho%3FTPE)

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

How to make to change %3F in &

and my last question I must have this at the final result

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

thank you

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Use the php "explode" function:

explode("&", $theurl);

You can manipulate the array from there and simply "implode" it back to your desired result:

[link]http://php.net/manual/en/function.implode.php

[link]http://php.net/manual/en/function.explode.php


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...