Well I know obfuscation is a bad idea. But I want all of my html code to come in one long single line. All the html tags are generated through PHP, so I think its possible. I knew replacing \n\r
from regular expression, but have no idea how to do this one. In case I am unclear here is an example
$output = '<p> <div class="title">Hello</div> </p>'; echo $output;
To be view in the source viewer as <p><div class="title">Hello</div></p>
“how to remove line break in html” Code Answer's -- One way is to delete the used (if used <br> tags). --!> <! -- The other solution is to use a little css and set the html elements (display to inline).
Use the String. replace() method to remove all line breaks from a string, e.g. str. replace(/[\r\n]/gm, ''); . The replace() method will remove all line breaks from the string by replacing them with an empty string.
Open TextPad and the file you want to edit. Click Search and then Replace. In the Replace window, in the Find what section, type ^\n (caret, backslash 'n') and leave the Replace with section blank, unless you want to replace a blank line with other text.
Maybe this?
$output = str_replace(array("\r\n", "\r"), "\n", $output); $lines = explode("\n", $output); $new_lines = array(); foreach ($lines as $i => $line) { if(!empty($line)) $new_lines[] = trim($line); } echo implode($new_lines);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With