php - How to put an array into a file? -


i file content array:

$array = file('sample.txt', file_ignore_new_lines); 

how reverse this? if have array how write file, each value in seperate line.

it not make sense put each value on different row. you're looking serialize.

if want each element on it's own line, use implode:

$str = implode("\n", $array); file_put_contents($file, $str); 

Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -