Forum Moderators: open

Message Too Old, No Replies

Generating HTML from delimited text

         

gray8110

5:04 pm on Jul 3, 2008 (gmt 0)

10+ Year Member



I send out a regular email newsletter that includes a set of ever changing links at the bottom. I'd like to automate the process for creating the HTML for these.

I start with a delimited text file, currently I'm just doing a find and replace to insert the HTML at each segment. Here's a rough example of the before and after.


Name, URL, Link Text
Name1, URL1, Link Text1
Name2, URL2, Link Text2
Name3, URL3, Link Text3

After the find and replace it might look like this


<table><tr>
<td><a name="Name" href="Link">Link Text</a></td>
<td><a name="Name1" href="Link1">Link Text1</a></td>
</tr>
<tr>
<td><a name="Name2" href="Link2">Link Text2</a></td>
<td><a name="Name3" href="Link3">Link Text3</a></td>
</tr></table>

I'm simplifying the code a bit, but that gives you the flavor. Is anyone aware of an app, tool or script that'll accomodate this. Basically I want to be able to define a stock set of rules for a series of automatic, successive find and replace operations to generate the HTML from the original text.

eelixduppy

5:07 pm on Jul 3, 2008 (gmt 0)



How are you sending the newsletter? I've constructed HTML emails like this and emailed them using PHP -- a custom script, of course.

gray8110

5:17 pm on Jul 3, 2008 (gmt 0)

10+ Year Member



It's going out through a third party email vendor for tracking purposes. They need the raw HTML code.

I can almost envision how I'd write PHP script to do this, but don't know that I'm strong enough with PHP to make it happen.

eelixduppy

5:21 pm on Jul 3, 2008 (gmt 0)



I'm sure you'd be able to write it. You'd have to use the explode [php.net] function to get each part. If you need further assistance we have a PHP forum [webmasterworld.com] that would be of assistance to you.