使用POST将PHP数组从页面传递到另一页

I have an Array $_POST['size']

I want to pass this on to the next page

at first i thought, well thats easy just pass it:

<input type="hidden" name="size" value="<?php echo $_POST['size'] ?>"/>

obviously this is wrong but is there a way to do it without doing this:

foreach ($_POST['size'] as $key => $value){
 echo '<input type="hidden" name="size['.$key.']" value="'.$value.'"/>';
}

Use sessions - this is a perfect example as to why.

Store $_POST['size'] in $_SESSION['size'] and get it from the session on the page you need it.

You could json_encode the array (as the value in the hidden element), and then json_decode in the next PHP page