5

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"

1 Answer 1

6

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.