Re: pack and unpack functions
| From: | Billy Harvey | Date: | Wed, 28 Jun 2000 02:06:18 +0000 |
| Subject: | Re: pack and unpack functions | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-3491@lists.php.net to get a copy of this message | ||
> Joseph V. "Jay" wrote:
> > I'm trying to take an array and pack() it and then pass it to the next form
> > as a hidden value. Once it gets to the next form I unpack this packed array
> > using the unpack() function the only problem is that I don't know what the
> > parameters are or what they mean and php.net doesn't really help out at all.
> > Is there anyway I can use this funciton or should I try another way of doing
> > this?
> >
> > Thanks,
> > Jay
> You could look at [un]serialize and [im][ex]plode as possible
> alternatives.
> David Robley
Depending on if this example fits what you're trying to do, you can
let PHP just create the arrays for you as it receives the form data:
--------------------------------------------------
<?
$num_names = 3 ;
echo "<form action='submit.php3' method=post>";
for ($i = 1 ; $i ,= $num_names ; $i++) {
echo "
First Name: <input name="first[]" type=text>
Last Name: <input name="last[]" typ=text>
";
}
echo "<input type=submit></form>";
?>
--------------------------------------------------
When this gets submitted, php will take the incoming first[] and
last[] and assign values to the array members one through three.
Perhaps a variation of this script is what you need..
Billy