This is a discussion on get array within the PHP Language forums, part of the PHP Programming Forums category; Hi, I have two arrays in previous page and use the arrays in next page. (Action page) how can I ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
kirke wrote:
> Hi, > I have two arrays in previous page and use the arrays in next page. > (Action page) > how can I do this? > > Thank you put them in a session? $_SESSION["someArr"] = $someArr; or post them to the next page via post (form) or via GET. This involves some encoding of the array. Session is probably the easiest way to go. Regards, Erwin Moller |
|
|||
|
kirke wrote:
> Hi, > I have two arrays in previous page and use the arrays in next page. > (Action page) > how can I do this? > > Thank you > You need to pass them onto the next page. You can do it in hidden fields on a form, the $_SESSION value, or even store them in a database and pass the key, i.e. in the form or $_SESSION or even a parameter in the URL of the next page. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== |
|
|||
|
<comp.lang.php>
<kirke> <6 Nov 2006 03:24:08 -0800> <1162812248.829522.49860@b28g2000cwb.googlegroups. com> > I have two arrays in previous page and use the arrays in next page. > (Action page) > how can I do this? > - write them to a flat file - read the flat file on the next page -- www.phpchatroom.co.uk |
|
|||
|
Krustov wrote:
> <comp.lang.php> > <kirke> > <6 Nov 2006 03:24:08 -0800> > <1162812248.829522.49860@b28g2000cwb.googlegroups. com> > > > I have two arrays in previous page and use the arrays in next page. > > (Action page) > > how can I do this? > > > > - write them to a flat file > > - read the flat file on the next page > > > -- > www.phpchatroom.co.uk This can be done with serialize and urlencode as follows. <?php if (isset($_REQUEST) { $decode_hidden = urldecode($_REQUEST['hidden_array_value']; $new_array = unserialize($decode_hidden); } $array[] = 'one'; $array[] = 'two'; $pass_array = serialize($array); $encode_array = urlencode($pass); print "<form>"; print "<input type='hidden' name='hidden_array_value' value='$encode_array' "; print "</form>"; ?> The serialized array must be urlencoded to handle the characters injected by the serialize command. Craig |