Re: Populating an array to the next script!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 7/7/06, Miguel Guirao <miguel.guirao@xxxxxxxxxxxxxxx> 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++){
        echo($hwGSM[$i]);
}

It should be pretty easy but I have not done it ever!

Regards,
Miguel Guirao

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.php

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux