douyingmou1389 2019-06-24 08:28
浏览 35

根据多维数组中给出的值创建URL

I have a multidimensional array. For each of the values in the array I want to create a URL:

<?php

$myArray = [
    [
        'name' => ` d a`,
        'surname' => `smith`,
        'place' => `a us`,
    ],
    [
        'name' => `d a e`,
        'surname' => `col`,
        'place' => `e n g land`,
    ],

 ];
include 'index_common.php';

and other file index_common.php URL is

 echo  "<a href=http://place/surname_action.php><h1>name</h1></a>";
  • 写回答

1条回答 默认 最新

  • dongyashun2559 2019-06-24 08:38
    关注

    Iam not sure to understood you right, but I would guess the following is the solution for your problem:

    See - http://docs.php.net/manual/da/function.http-build-query.php

    There is a function given an array returns an querystring, see the following example from php manual.

    <?php
    $data = array('foo'=>'bar',
                  'baz'=>'boom',
                  'cow'=>'milk',
                  'php'=>'hypertext processor');
    
    echo http_build_query($data) . "
    ";
    echo http_build_query($data, '', '&amp;');
    
    ?>
    
    foo=bar&baz=boom&cow=milk&php=hypertext+processor
    foo=bar&amp;baz=boom&amp;cow=milk&amp;php=hypertext+processor
    

    also supports complex / nested arrays

    评论

报告相同问题?

悬赏问题

  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程