Jump to content

Recommended Posts

Do you mean you want to pass a group of values in a form as a hidden field?  If so then I'd suggest something like this in your form

[code]<input type="hidden" name="myformarray" value="This,Is,An,Array,Of,Words">[/code]

Then make your php look like this:

[code]
<?php
$myarray = explode(",", $_POST['myformarray']);

echo "<pre>\n";
var_dump($myarray);
echo "</pre>\n";
?>
[/code]

Regards
Huggie
Thanks for response!


exactly what i am tryign to do is passing an array like .

i tried it but it is showing empty array even though there are some values in the actual array i am trying to pass.

[code]$array_name=array("1","2","3");
<input type="hidden" name="test_array" value="<?=$array_name;?>">[/code]


So please  tell me how to pass this as hidden?


Regards,
Joshi.
You can also serialize the array, pass the serialized value and unserialize it when you process the form.
[code]<?php
<?php
$array_name = array(1,2,3);
$myvarstring = htmlentities(serialize($array_name),ENT_QUOTES);
?>

<input type="hidden" name="test_array" value="<? echo $myvarstring;?>">
?>[/code]

Ken
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.