views:

49

answers:

1

I'm working on a WordPress plugin that exports posts and associated data into a tab-seperated text format. It's almost finished, but I'm struggling to find the best method to re-process HTML into single strings.

I'm using a combination of preg_replace and htmlentities, but it's getting a little messy.

I'm sure there must be a preferred method for doing this, so I thought I would check with you? I can't find anything suitable on Google.

+1  A: 

There's no single sure fire way but some simple regex would do the trick:

// remove convert newlines and multiple spaces into 1 space
$html = preg_replace($html, "\s+|\n+|\r", ' ');
TravisO
OK, guess I'm on the right track then. Thank for the confirmation and comments!
trnsfrmr