Well, I want to make PHP always write in the first line in a text file, that is, I want it to never write below or in the text.
Put simply, I want him to write before the texts.
Is it possible?
Well, I want to make PHP always write in the first line in a text file, that is, I want it to never write below or in the text.
Put simply, I want him to write before the texts.
Is it possible?
Yes it is possible, but there is no specific command, if that's what you want to know.
file_put_contents($filename, $data . file_get_contents($filename));
Do not forget to break the line: $data = 'Belezura\n';
I believe this is what you want to do:
$nome_arquivo = 'c:\texto.txt';
$arquivo = file($nome_arquivo);
$arquivo = implode("\n",$arquivo);
$string_a_ser_inserida = "PROPRIEDADE DE : PABLO MARTINS" . PHP_EOL;
file_put_contents($nome_arquivo , $string_a_ser_inserida . $arquivo);