I've been looking at some question of this style but I have not seen anything that serves me, so I put my question to you.
I have an object called $detalle
that has an array with other arrays inside (excuse me, but I do not remember the name of this type of array) and I write the data using print_r()
and file_put_contents()
in a file called detallesPedido.txt
.
This is the code I use:
$contenido = print_r($detalle, true);
file_put_contents("detallesPedido.txt", $contenido);
My problem is that in the file detalles.txt
shows me all the data in the same line and I can not get each element of the array to be shown in a line.
I tried to use fwrite()
but the same thing kept happening to me.
EDIT : Following the comment of @ A.Cedano I would like it to be shown as follows:
Array (
[a] => manzana
[b] => banana
[c] => Array (
[0] => x
[1] => y
[2] => z )
Actually the bleeding is a little indifferent, but it is something like a "list".
EDIT2 : I've tried a simpler array.
array( 'mensaje'=>"el correo se ha enviado",
'datos'=> "m");
And it keeps coming online, instead of how it would correspond to print_r
.
Thanks in advance!