| |||||||||||
| |||||||||||
removing carriage returns/line feeds/line breaks Posted by Stooshie (Stooshie), 13 March 2006 Hi there,I am currently working on code to publish a flat xhtml page by parsing a second php page that takes content from a database (the flat page loads quicker for the public). Anyway, I have the following code to reduce the size of the page a little. Code:
However, the output is all on one line and older browsers may struggle with this. What I would ideally like is to replace 2 or more carriage returns, line feeds or line breaks with 1 line break. I've tried things like: Code:
but to no avail. I've been struggling with this regular expression for a while and my head is now sore!! .Any ideas. Thanks. Andrew. ps. I know the second regular expression to remove tabs can probably be added to the first one, but I was trying to get the first one working before I attempt that. Posted by admin (Graham Ellis), 13 March 2006 At first glance, I would replace all the new lines and returns with a tab and then replace all groups of 2 or more tabs with a new line. That way, you're left with single tabs or single new lines.Code would look something like this: $line = ereg_replace("[\n\r]", "\t", $line); $line = ereg_replace("\t\t+", "\n", $line); This page is a thread posted to the opentalk forum
at www.opentalk.org.uk and
archived here for reference. To jump to the archive index please
follow this link.
| |||||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 707126 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho | |||||||||||