I have a text file that looks like:
Line one
Line two
Line three
I would like to convert it to:
return array(
'Line one',
'Line two',
'Line three'
);
And save it as a new file. I don’t want to perform the same explode/preg_split over and over, that really doesn’t make sense. I simply want to create a static file from the original file, and update it when I update the original file.
How would I go about doing this?
Use the
filefunction to read in the file:And to output it, use the
file_put_contentsandimplode: