-4
I’m cracking my head and I’m already out of ideas, summing up my code is like this:
<?php
$var = 'arquivo_1'; // podendo ser arquivo_1 ou arquivo_2
$arquivo_1 = array(
"algo1" => "alguem1",
"algo2" => "alguem2"
);
$arquivo_2 = array(
"algo1" => "alguem3",
"algo2" => "alguem4"
);
// a minha função é assim:
function array_file_writte($file_array,$array){
$content = serialize($array);
$fd = @fopen($file_array, 'w+');
fwrite($fd,$content);
fclose($fd);
chmod($file_array, 0644);
return true;
}
// se fosse assim fucionaria corretamente:
array_file_writte($file_array,$arquivo_1);
// mas o valor da variavel $var muda, então eu precisaria fazer assim:
$var_selecionada = '$'.$var;
array_file_writte($file_array,$var_selecionada);
//algum metodo???
// mas não dá certo por que o que ele grava no arquivo acaba não sendo a variavel serializada, alguma idéia????
What is the doubt? was not clear, could [Edit] the question and add the details.
– rray
I think I get it, try calling it that
array_file_writte($file_array,$$var);
– Augusto
at that point
array_file_writte($file_array, $arquivo_1);
the variable$file_array
not defined, so what does it contain? The file name?– Neuber Oliveira
The question is not clear, please edit it and give more details.
– Murilo Melo
It is not clear enough, what the proposed problem, I recommend seeing this link and edit your question.
– WMomesso
If I understand correctly you want $$var instead of '$'. $var. And this doubt has nothing to do with arrays like the title and hashtag left to understand.
– Antonio Alexandre