I am trying to post an array in a hidden field and want to retrieve that array after submitting a form in PHP.
$postvalue = array(\"a\", \"b\", \"c\");
Use:
$postvalue = array("a", "b", "c");
foreach($postvalue as $value)
{
echo '<input type="hidden" name="result[]" value="'. $value. '">';
}
And you will get $_POST['result'] as an array.
print_r($_POST['result']);
You can use serialize and base64_encode from the client side. After that, then use unserialize and base64_decode on the server side.
Like:
On the client side, use:
$postvalue = array("a", "b", "c");
$postvalue = base64_encode(serialize($array));
// Your form hidden input
<input type="hidden" name="result" value="<?php echo $postvalue; ?>">
On the server side, use:
$postvalue = unserialize(base64_decode($_POST['result']));
print_r($postvalue) // Your desired array data will be printed here