我想将一个数组写入文件,但不是这样:
array (
0 => 'Something 1
',
1 => 'Something 2
',
2 => 'Something 3
'
)
它看起来应该像这样:
Something 1
Something 2
Something 3
是否可以?我目前正在使用此方法将数组写入文件:
file_put_contents('array.txt', var_export($array, TRUE));
一个非常简单的方法:
file_put_contents('array.txt', implode(PHP_EOL, $array_data));
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句