Passing an array to $_GET

Hi

Got a little problem.
I generate a HTML link with

gallery.php?files='.$files.'

as HREF.

Now I want to $_GET the data $_GET[files]
The problem here is that $files is a multidimensional array.
When I use GET it says something like assigning an array to string blablabla,
I tried adding after files in the link but then echoing produces [0]=A, [1]=r, as A.r.r.a.y.

Or is there any other way to provide the array to the other php script?
Please help me out on this one, I’m new at PHP.

echo ‘<a href="gallery.php?img_index=’.($img_index-1).‘"></a>’."
";

You could also serialize the value:

The value to be serialized. serialize() handles all types, except the resource -type. You can even serialize() arrays that contain references to itself. Circular references inside the array/object you are serializing will also be stored. Any other reference will be lost.

From http://php.net/manual/en/function.serialize.php

That will allow you to call unserialize() on the back end, and you’ll be good to go.

If you want something to persist over multiple pages you can store it in the session

$_SESSION[‘whatever’] = array(‘some’, ‘vars’, ‘or’, ‘other’);

http://us.php.net/manual/en/function.http-build-query.php

Hmm, thanks for the replies.
It seems to me that the link can size up really quickly in my case.
Is there another way of passing an array to another page?

Or maybe I should generate an javascript array, and put it in a separate file, and link to it, so all of my pages could have all the info.


<?php
$files = array('a','b','c');
$link = 'gallery.php';

echo $link.'?files[]='.implode('&files[]=',$files);
?>

Hey I’ve run in to another problem.
How does one do simple arithmetic inside an echo statement:

echo '<a href="gallery.php?img_index='.$img_index.'"></a>'."\
";

I now want to add or subtract from $img_index,
how can this be done?

‘.$img_index.-1’ doesnt work
‘.$img_index -1.’ doesnt work.

I’m not yet completly familiar with the syntax