Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 从http_build_query()重建数组_Php_Arrays_Get - Fatal编程技术网

Php 从http_build_query()重建数组

Php 从http_build_query()重建数组,php,arrays,get,Php,Arrays,Get,我会尽量把这个简短而甜蜜。我将一些变量从一个页面传递到下一个页面,我希望在下一个页面上重建该数组 <?php /* $user is and array of data specific to the user */ $user_id = $user["userId"]; // we'll pretend the value is 13 $manager_ids = array(42,56,76); $url = './mod-super-admin/edit-relationsh

我会尽量把这个简短而甜蜜。我将一些变量从一个页面传递到下一个页面,我希望在下一个页面上重建该数组

<?php
 /* $user is and array of data specific to the user */
 $user_id = $user["userId"]; // we'll pretend the value is 13
 $manager_ids = array(42,56,76);
 $url = './mod-super-admin/edit-relationship.php?edit=true&repId=' . $user_Id  . '&';
 $url .= http_build_query($manager_ids, 'manager_');
?>

我建议在URL中创建一个管理器数组:

$url .= http_build_query(array('managers' => $manager_ids));
收益率:

managers%5B0%5D=42&managers%5B1%5D=56&managers%5B2%5D=76
当PHP收到时,它将被解释为:

managers[0]=42&managers[1]=56&managers[2]=76
因此,
$\u GET['managers']
将产生:

Array
(
    [0] => 42
    [1] => 56
    [2] => 76
)

刚刚测试了这个,它工作得非常好,完全符合我的要求。泰姆!问题已解决,请为您投票!:)