What is the best way to write an array to a text/html file ?
I've written a short script, which loads an html file into an array, runs through it removing all <something> tags and now need to save it as a different file.
Should I use fopen, tempnam or ?
Soren O'Neill
Howto write an array to a file
Moderator: General Moderators
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
You can also use implode() to convert the array to a long string.
From the user notes on implode():
From the user notes on implode():
Mac$file_text = implode('', file('data.htm'));
slurps file data.htm into variable $file_text unchanged (vs the file content). Newlines are all in the right place because newlines were the last char in each array element. That's how file() splits the input.