Transporting an array

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hame22
Forum Contributor
Posts: 214
Joined: Wed May 11, 2005 5:50 am

Transporting an array

Post 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
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post 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.
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post 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);
Post Reply