Pass array from one page to another

后端 未结 4 1605
时光说笑
时光说笑 2021-01-13 04:55

I have an array containing some values, say

arr[\'one\'] = \"one value here\";
arr[\'two\'] = \"second value here\";
arr[\'three\'] = \"third value here\";
         


        
4条回答
  •  滥情空心
    2021-01-13 05:28

    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 "";
    

    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

提交回复
热议问题