Existem duas formas para isso, que conheço.
Usando JSON (citado pelo @rray):
Para o formulário:
<?
$json = json_encode($array_dos_pagamentos);
// Isto ira converter a array em json
?>
<input type="hidden" name="result" value="<?= htmlentities($json, ENT_QUOTES, 'UTF-8') ?>">
Para receber os dados:
<?
$array = json_decode($_POST['result'], true);
// Isto irá tornar o JSON em array
?>
Informações em http://php.net/manual/pt_BR/function.json-encode.php
Usando Serialize + HMAC (ou AES-CGM):
Se não puder usar o JSON existe uma alternativa não muito recomendada, usando serialize()
, lembre-se de nunca utilizar serialize()
sozinho, vise documentação.
Para o formulário:
<?
$serialize = serialize($array_dos_pagamentos);
$hmac = hash_hmac('sha384', $serialize, 'SUA_SENHA');
$value = $hmac.$serialize;
?>
<input type="hidden" name="result" value="<?= htmlentities($value, ENT_QUOTES, 'UTF-8') ?>">
Para receber os dados:
$value = $_POST['result'];
$hmac = mb_substr($value, 0, 96, '8bit');
$serialize = mb_substr($value, 96, null, '8bit');
if(hash_equals($hmac, hash_hmac('sha384', $serialize, 'SUA_SENHA'))){
$array = unserialize($serialize);
}
Isso irá prevenir que o valor do input seja alterado pelo usuário, o que é um grande problema ao se utilizar o serialize()
.
Informações em http://php.net/manual/pt_BR/function.serialize.php.