Tuxicity's source

January 9, 2007

Transform plain text files into Web pages automatically with this PHP script

Filed under: Blogroll — tuxicity @ 8:38 am

Recently, an old friend of mine rang me up to ask for help. He’d been working as a journalist for many years, and had recently received reprint rights to a number of his earlier columns.

He was eager to publish his past work on the Web; however, his columns were all saved as plain-text files and he had neither the time nor the inclination to learn HTML and convert them to Web pages. Since I was the only geek in his phone book, he’d called me to see if I could help him.

“Let me take care of it”, I said. “Call me back in an hour”, I said. And sure enough, when he called back a couple of hours later, I had a solution waiting for him. It involved a little bit of PHP, and it earned me his eternal thanks and a crate of wine.

So what did I do in that hour? That’s where this article comes in. I’m going to show you how you can use PHP to quickly transform plain ASCII text into perfectly readable HTML markup.

To begin, let’s look at an example of one of the raw text files my friend wanted to convert:

Builder AU :: More…

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: