gpt4 book ai didi

php - 如何解码由http_build_query编码的url

转载 作者:行者123 更新时间:2023-12-03 22:28:04 25 4
gpt4 key购买 nike

我想在 url 中传递数组,所以我使用 http_build_query 进行了编码

$filterArray = array('OrderNo'=>$_REQUEST['txtorderno'],
'StoreName'=>$_REQUEST['txtstorename'],
'PartyCode'=>$_REQUEST['txtpartycode'],
'fromdate'=>$_REQUEST['txtfromdate'],
'todate'=>$_REQUEST['txttodate'],
'minamount'=>$_REQUEST['txtminamount'],
'maxamount'=>$_REQUEST['txtmaxamount']);

$data = array('DistributorId' => $_GET['DistributorId'], 'StoreId' => $_GET['StoreId'],'filterArray' => http_build_query($filterArray));

最后我的网址是这样生成的
http://localhost/test/orderdetails.php?DistributorId=&StoreId=&filterArray=OrderNo%3D1%26StoreName%3D2%26PartyCode%3D3%26fromdate%3D04%252F26%252F2017%26todate%3D04%252F27%252F2017%26minamount%3D111%26maxamount%3D222

现在我如何从 url 获取所有参数?

我试图打印 filterArray 参数,如
echo "<pre>";
$arr = (urldecode($_GET['filterArray']));
var_dump($arr);

它打印
string(99) "OrderNo=1&StoreName=2&PartyCode=3&fromdate=04/26/2017&todate=04/27/2017&minamount=111&maxamount=222"

最佳答案

您可以使用 parse_str[1]:

<?php
$inputStr = 'OrderNo=1&StoreName=2&PartyCode=3&fromdate=04/26/2017&todate=04/27/2017&minamount=111&maxamount=222';

parse_str($inputStr, $output);

var_dump($output);
?>

示例: https://3v4l.org/toiKf

[1]: http://php.net/manual/de/function.parse-str.php

关于php - 如何解码由http_build_query编码的url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43654032/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com