0
I needed to generate some data by taking the contents of a $_POST and saving it to a file to process it later.
I did it this way:
$dados = $_POST;
$dados = var_export($dados, true);
$handle = fopen('posttemp.txt', 'a');
fwrite($handle, $dados);
fclose($handle);
So far so good, if I open the file posttemp.txt this is its content.
array (
'id' => '1832007',
'post' =>
array (
'codigo' => '39063',
'autor' => 'Christiano',
),
'conteudo' =>
array (
'id' => '2526167',
'dataInicio' => '2017-08-03 21:30:43',
'dataFinalizada' => '2017-08-03 21:30:47',
'status' => 'Publicado',
),
'autor' =>
array (
'codigo' => '37276',
'email' => '[email protected]',
'nome' => '1 Lift Gold',
'quantidade' => '1',
)
)
Now I need to get the contents that were saved in posttemp.txt and turn it back into a variable so it can send again via POST.
Why don’t you use the
serialize
andunserialize
?– Woss