Pass array from one page to another

后端 未结 4 1601
时光说笑
时光说笑 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:39

    You can pass the values by query parameters, too.

    header('Location: detail.php?' . http_build_query($arr, null, '&'));
    

    And you can get the array in the detail.php like this:

    // your values are in the $_GET array
    echo $_GET['one'];  // echoes "one value here" by your example
    

    Be aware that if you pass values by GET or POST (hidden input field), they can be changed by the user easily.

提交回复
热议问题