如何在PHP中发布数组?

时间:2012-12-22 07:32:31

标签: php arrays post

如何将此数组发布到另一个页面。

Array
(
    [0] => Array
        (
            [0] => Client Name
            [1] => Task ID
            [2] => Sub-Task Id
            [3] => Task Specification
            [4] => Billable Minutes
            [5] => Total Spent Time
            [6] => Handled By
        )

    [1] => Array
        (
            [0] => Client1
            [1] => TAS1
            [2] => -
            [3] => 90
            [4] => 01:20:51
            [5] => Vinodkumar M
        )

    [2] => Array
        (
            [0] => Client2
            [1] => TAS2
            [2] => -
            [3] => 60
            [4] => 02:04:42
            [5] => Vinodkumar M
        )

)

1 个答案:

答案 0 :(得分:2)

你可以把它放在会话中:

session_start();
$_SESSION['array_name'] = $array_name;

或者,如果您想通过表单发送,可以serialize

<input type='hidden' name='input_name' value="<?php echo htmlentities(serialize($array_name)); ?>" />

$passed_array = unserialize($_POST['input_name']);

请注意,要使用序列化数组,您需要使用POST作为表单的传输方法,因为GET的大小限制大约为1024个字符。

我尽可能使用会话。