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

时间:2019-06-24 08:28:42

标签: php

我有一个多维数组。我想为数组中的每个值创建一个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';

和其他文件index_common.php URL是

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

1 个答案:

答案 0 :(得分:0)

我不确定您是否理解正确,但我想以下是解决您问题的方法:

请参阅-http://docs.php.net/manual/da/function.http-build-query.php

给定数组的函数会返回查询字符串,请参见php手册中的以下示例。

val text: String = "file-client-and-reports_20190512_010012_c.csv"
val text2 = text.replaceAll("""(?:_[0-9]+)+_c(?=\.[^.]+$)""","")
println(text2)
// => file-client-and-reports.csv

还支持复杂/嵌套的数组

相关问题