Save an array as a text file?

0

I want to save the values of an array in a text file

Example of What I Want

I have this currently in the file:

Hola
Como Estas

I use the file () function to get the contents of the text file as an array, modify it and save it again:

$array = file("test.txt")
//Edito la primera linea del array
$array[0] = "Si"
//Guardo el array modificado devuelta en el archivo de texto
file_put_contents('test.txt', print_r($array, TRUE));

Expected Output:

Si
Como estas

But I Get Out:

Array
(
    [0] => Si
    [1] => Como estas
)

How could I fix this?

    
asked by Richard Hasgton 22.11.2017 в 14:56
source

0 answers