Skip to content

Instantly share code, notes, and snippets.

@nhaskins
Created May 11, 2010 02:08
Show Gist options
  • Save nhaskins/396825 to your computer and use it in GitHub Desktop.
Save nhaskins/396825 to your computer and use it in GitHub Desktop.
mailchimp table cleaner/font tag adder
//fontThisTable() inserts font tags before and after all the td tags. Size and style are optional.
function fontThisTable($someTable, $fontSize, $fontStyle){
if(!$fontSize){$fontSize = '2';}
if(!$fontStyle){$fontStyle = 'Arial';}
$someTable = preg_replace('|<td.*?>|', '<td>', $someTable);
$someTable = preg_replace('|<td>|', '<td><font face="'.$fontStyle.'" size="'.$fontSize.'">', $someTable);
$someTable = preg_replace('|</td>|', '</font></td>', $someTable);
return $someTable;
}
@nhaskins
Copy link
Author

See the problem is with email HTML is that a lot of mail clients strip out styling. In this case, I'm going to copy a table from a page, and send it to a Mailchimp template. I wanted to take the table as it was on the site, strip out class data, and then insert the font tags for each one.

Its 1996 at its finest, which means there is a good chance the majority of email clients will render this font the way i want it to happen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment