Re: Populating an array to the next script!
| From: | Dimiter Ivanov | Date: | Fri, 07 Jul 2006 07:59:08 +0000 |
| Subject: | Re: Populating an array to the next script! | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-42186@lists.php.net to get a copy of this message | ||
On 7/7/06, Miguel Guirao <miguel.guirao@mail.telcel.com> wrote:
Hello, Is there a way to populate an array from one script to the next one? I'm using a form, and a hidden field for such desire: <input name="hwt[]" type="hidden" value="<?php echo($hwGSM);?>"> but it returns this: <input name="hwt[]" type="hidden" value="Array"> then I pretend to read the array again at the target script by coding the following: $hw=$_POST['hwt']; $hwGSM=$hw[0]; for($i=0;$i<=$maxpoint;$i++){You have to make inputs for every element of the array. something like this : foreach($hwGSM AS $key => $value){ echo "<input name='hwt[$key]' type="hidden" value='$value'> } And then after the submit you will have your array $hwt. PHP will make an array out of all that inputs. Another option you can use if you want a single input is to serialize the array, on the form, and then unserialize it in the script processing the form. http://bg2.php.net/manual/en/function.serialize.php http://bg2.php.net/manual/en/function.unserialize.phpecho($hwGSM[$i]);} It should be pretty easy but I have not done it ever! Regards, Miguel Guirao