canadabeeau Posted February 14, 2010 Share Posted February 14, 2010 Hi guys, I need help making a PHP script which will remove "new lines" I have a page called text.php, I want index.php to read test.php and remove all the new lines so the page is all on one line. test.php now <?php echo "aa"; $a = "bgaga"; echo $a; ?> test.php wanted <?php echo "aa"; $a = "bgaga"; echo $a;?> Quote Link to comment https://forums.phpfreaks.com/topic/192013-trim/ Share on other sites More sharing options...
salathe Posted February 14, 2010 Share Posted February 14, 2010 To read the PHP file into a string, file_get_contents makes that easy. To remove newlines, you could just use str_replace; to take care of newlines and indenting whitespace, a regular expression could be used (like /(?:\v\h*)+/ for one example). Quote Link to comment https://forums.phpfreaks.com/topic/192013-trim/#findComment-1012070 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.