note 49098 added to function.preg-replace

From: Date: Sun, 16 Jan 2005 19:42:37 +0000
Subject: note 49098 added to function.preg-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-83458@lists.php.net to get a copy of this message
A follow-up to my previous posting on removing whitespace using preg_replace(). If you're just interested in removing SPACE characters only, keeping all \n or \r\n -- then try the following: <? $str = preg_replace("/([ ]+)?(\<.+\>)([ ]+)?/", "$2", ob_get_contents()); ?> Your HTML will format as if a TRIM() method was called on each line. <html> <head> <title>My Fantastic Website! </title> </head> <body> <?=$str?> </body> </html> will output as: <html> <head> <title>My Fantastic Website! </title> </head> <body> This is some text </body> </html> Jason ---- Manual Page -- http://www.php.net/manual/en/function.preg-replace.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+49098 Delete -- http://master.php.net/manage/user-notes.php?action=delete+49098&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+49098&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+49098&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+49098&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+49098&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+49098&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+49098&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#83458) next »