duandou8120 2019-07-16 09:34
浏览 115
已采纳

如何用http_build_query构造url,但显示没有变量的值?

I'm trying to generate an URL from all values of two arrays by using http_build_query:

Array 1:

$server = array($_GET["server"]);

Array 2:

$data = array($_GET["z_koord"],
        $_GET['x_koord'],
        $_GET["y_koord"],);

The code for generating URL I currently have written:

$server = array(''=>$_GET["server"]);
$data = array($_GET["z_koord"],
        $_GET['x_koord'],
        $_GET["y_koord"],);
$url = '.tile.openstreetmap.org';
$saite = http_build_query($server). $url ."/". http_build_query($data,'','/').".png";

Here's the URL made of code above:

=c.tile.openstreetmap.org/0=6/1=90/2=110.png

Here's the structure of url I'm trying to make:

c.tile.openstreetmap.org/6/90/110.png

I have reviewed some other posts about this topic like this one and this, but those posts aren't completely useful for solving my problem.

So I hope someone with greater knowledge could show me a solution or at least a hint how to get closer to solution.

  • 写回答

2条回答 默认 最新

  • duandao8607 2019-07-16 09:37
    关注

    You could use implode():

    $server = $_GET["server"];
    $data   = [$_GET["z_koord"],
               $_GET['x_koord'],
               $_GET["y_koord"]];
    $url    = '.tile.openstreetmap.org';
    $saite  = "$server/$url/" . implode('/', $data) . ".png";
    

    I'm not sure about some things in this code, but the implode() should do the job.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥500 我要找大模型一体机产品手册和应用案例
  • ¥60 用r语言进行数据分析
  • ¥20 关于游戏c++语言代码问题
  • ¥15 如何制作永久二维码,最好是微信也可以扫开的。(相关搜索:管理系统)
  • ¥15 delphi indy cookie 有效期
  • ¥15 labelme打不开怎么办
  • ¥35 按照图片上的两个任务要求,用keil5写出运行代码,并在proteus上仿真成功,🙏
  • ¥15 免费的电脑视频剪辑类软件如何盈利
  • ¥30 MPI读入tif文件并将文件路径分配给各进程时遇到问题
  • ¥15 pycharm中导入模块出错