Page 1 of 1

Transporting an array

Posted: Thu Feb 16, 2006 6:35 am
by hame22
Hi

I have an array:

Code: Select all

$credit_details = array(
 				'credit_code' => $credit_code,
 				'credit_value' => $credit_value,
 				'credit_price' => $credit_price,
 				'credit_name' => $credit_name,
 				'credit_desc' => $credit_desc
 				);
which i wish to transport to another page using a POST form, where I can then use the individual variables.

Is this possible and how do I go about achieving this?


thanks in advance

Posted: Thu Feb 16, 2006 6:58 am
by onion2k
serialize() the array, put the resulting string into either a hidden form variable, or a $_SESSION variable, and then unserialize() it on the next page.

Posted: Thu Feb 16, 2006 7:19 am
by Jenk
If using sessions, you don't need to serialize() it, you can just assign the array to a session variable like a normal variable:

Code: Select all

$_SESSION['var'] = array(1,2,3,4,5,6);