Reputation: 5283
i want to pass array in url, so i have encoded using 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));
finally my URL is generated like this
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
now how do i get all the parameters from url ??
i tried to print filterArray parameter like
echo "<pre>";
$arr = (urldecode($_GET['filterArray']));
var_dump($arr);
it prints
string(99) "OrderNo=1&StoreName=2&PartyCode=3&fromdate=04/26/2017&todate=04/27/2017&minamount=111&maxamount=222"
Upvotes: 5
Views: 7297
Reputation: 6379
You can use 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);
?>
Example: https://3v4l.org/toiKf
[1]: http://php.net/manual/de/function.parse-str.php
Upvotes: 6