Pass array from one page to another

php

Solution

The easiest way to do this would be to use the session to store the array from one page to another:

session_start();
$_SESSION['array_to_save'] = $arr;

More info on the sessions : http://php.net/manual/en/function.session-start.php

If you don't want to use session you can do something like this in your first page

$serialized =htmlspecialchars(serialize($arr));
echo "<input type=\"hidden\" name=\"ArrayData\" value=\"$serialized\"/>";

and in the other one you retrieve the array data like this :

$value = unserialize($_POST['ArrayData']);

Solution found here : https://stackoverflow.com/a/3638962/1606729

Problem

I have an array containing some values, say ``` arr['one'] = "one value here"; arr['two'] = "second value here"; arr['three'] = "third value here"; ``` I this values are in the page home.php and at the end of the page it is redirected to page detail.php Now i want to pass this array from page home.php to detail.php when direct occur. In how many ways I can send this value using post and get method. Also if possible show me how to receive and print those values in detail.php page. An example of each type is much appreciated.

Original source