SaJmoN SaJmoN - 1 year ago 79
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 Source

A very simple method:

file_put_contents('array.txt', implode(PHP_EOL, $array_data));
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download