SaJmoN SaJmoN - 23 days ago 6
PHP Question

PHP - How to write an array to a file without any array numbers and arrows?

I want to write an array to a file, but instead of looking like this:

array (
0 => 'Something 1
',
1 => 'Something 2
',
2 => 'Something 3
'
)


It should look like this:

Something 1
Something 2
Something 3


Is it possible? I'm currently using this method to write an array to a file:

file_put_contents('array.txt', var_export($array, TRUE));

Answer

A very simple method:

file_put_contents('array.txt', implode(PHP_EOL, $array_data));
Comments