$idArray = array(1,2,3,4);
can I write this line in HTML?
Use parse_str function
$str = "first=value&arr[]=foo+bar&arr[]=baz";
parse_str($str);
echo $first;
Use serialize and unserialize PHP function.
This function giving you storable (string) version of array type.
For more infomation about usage read
http://php.net/manual/en/function.serialize.php
and http://www.php.net/manual/en/function.unserialize.php
serialize() your array first and pass that through. Then call unserialize() on it. http://ie.php.net/serialize
You could use serialize and & serialize along side with urlencode e.g.
On Sending you can send them like these:
<?php
$array1 = Array(["key1"]=>"value1",["key2"]=>"value2");
$array2 = Array(["key1"]=>"value1",["key2"]=>"value2");
$data1="textdata";
$urlPortion= '&array1='.urlencode(serialize($array1)).
'&array2='.urlencode(serialize($array2)).
'&data1='.urlencode(serialize($data1));
//Full URL:
$fullUrl='http://localhost/?somevariable=somevalue'.$urlPortion
?>
On Receiving you can access them as:
<?php
$destArray1=unserialize($_GET['array1']);
$destArray2=unserialize($_GET['array2']);
$destData1=unserialize($_GET['data1']);
?>
And Voila, you can attach that url on ajax request or normal browser page.
Another option (even nice looking, I'd say):
<form method='POST'>
<input type="hidden" name="idArray[]" value="1" />
<input type="hidden" name="idArray[]" value="2" />
<input type="hidden" name="idArray[]" value="3" />
<input type="hidden" name="idArray[]" value="4" />
</form>
But of course it gets sent as POST. I wouldn'r recommend sending it with serialize since the output of that function can get pretty big and the length or URL is limited.
with GET:
<form method='GET'>
<input type="hidden" name="idArray[]" value="1" />
<input type="hidden" name="idArray[]" value="2" />
<input type="hidden" name="idArray[]" value="3" />
<input type="hidden" name="idArray[]" value="4" />
</form>
A session is a much safer and cleaner way to do this. Start your session with:
session_start();
Then add your serialized array as a session variable like this:
$_SESSION["venue"] = serialize($venue);
The simply call up the session variable when you need it.