Home > PHP, Programming > Open File Then Create New One

Open File Then Create New One

June 28th, 2009

I have a text file (FILE A) with the following data on each line:
post title, post url, post category

So, the entire file looks like this:
First post title, http://mysite.com/hardcodedlink1, category
2nd post’s title, http://mysite.com/hardcodedlink2, category-two
Title to post #3, http://mysite.com/hardcodedlink3, category3

What I want to do is loop through the file and convert each line to this format:

<url>http://mysite.com/hardcodedlink1</url>
<title>First post title</title>
<category>category</category>

<url>http://mysite.com/hardcodedlink2</url>
<title>2nd post’s title</title>
<category>category-two</category>

<url>http://mysite.com/hardcodedlink3</url>
<title>Title to post #3</title>
<category>category3</category>

These conversions should not be written in FILE A. They should be written in FILEB, which is a file that will need to be created by the script.

100% escrow provided if requested in your bid.

If your bid says Immediate delivery, I will expect the script to be completed within 30 minutes of the project beginning, not 1 hour. There is an option for the number of hours for delivery, so please fill out the form correctly.

Thanks.


Open File Then Create New One

Comments are closed.
Bear