You can use implode _or_ serialize for this.

  $arr = array('a','b','c','d');

  $vars1 = implode('|', $arr); // a|b|c|d
  $vars2 = serialize($arr);    // try it :)

And send one of the above strings through your 
"hidden" form element.

Then upon use, either explode or unserialize it.
Also consider using urlencode() in addition to 
one of the above methods.  Anyway:

  $arr1 = explode('|', $vars1);
  $arr2 = unserialize($vars2);

Ah yes, our arrays are back :)

Regards,
Philip Olson




On Wed, 24 Apr 2002, Pushkar Pradhan wrote:

> I want to pass a 1 dim. array through a form, I use the hidden field and
> do as follows:
> <form method=POST ACTION=\"updateHTML.php\">
> <input type=hidden name=layer[] value=\"";
> foreach($layer as $lay) {
>    print "$lay ";
> }
> print "\">
> This generates the foll. source:
> <form method=POST ACTION="updateHTML.php">
> <input type=hidden name=layer[] value="a b c d e f g h ">
> 
> where actually it should be $layer[] = "a", "b", "c", ....
> i.e. it doesn't remain an array anymore and thus I cannot do array
> operations (eg. array_slice etc.) on it.
> Can anyone tell how I can pass it to my forms as an array? Thanks
> 
> 
> -Pushkar S. Pradhan
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 



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

Reply via email to