note 15297 added to function.ereg-replace

From: Date: Wed, 05 Sep 2001 00:09:54 +0000
Subject: note 15297 added to function.ereg-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-17624@lists.php.net to get a copy of this message
To strip out everything before <body> and after </body> (including the body tags themselves), you can use the following: $contents = ereg_replace (".*<body[^>]*>", "", $contents); # replace everything after </body> $contents = ereg_replace ("</body>.*", "", $contents); The first line says "replace everything before <body, then everything to the first >." I use this for a tiny content management system. We can then add our own system-generated title and meta tags. BTW, I find ereg_replace to be of greater value than preg_replace because ereg_replace uses all lines of the document by default (especially handy in this example, as we may have many lines of header and footer to remove.) By default, preg_replace only finds and replaces on one line of the document at a time. Thanks to hoppysean for his help with the first example. http://www.php.net/manual/en/function.ereg-replace.php

« previous php.notes (#17624) next »