Re: Help on copying part of a text file

From: Date: Sat, 17 Jul 2004 00:47:27 +0000
Subject: Re: Help on copying part of a text file
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-190791@lists.php.net to get a copy of this message
C.F. Scheidecker Antunes wrote:
Hello all, I need some help on the following: I need to extract a paragraph from a text file that is delimited with a --start-paragraph-- and --end-paragraph-- However, after --start-paragraph-- there's a blank line that I need to remove. The delimiter --start-paragraph-- might be one the first line or it might be on any middle line of the line. That is, --start-paragraph line starts at some point on the file. Here's na example: --start-paragraph-- This is a paragraph that I need to extract with a php function and return just the string of it. --end-paragraph-- After I run the function extract_paragraph($content) I should get the string:
function extract_paragraph($content) { $start = '--start-paragraph--'; $end = '--end-paragraph--'; preg_match("/$start(.*)$end/s",$content,$matches); return trim($matches[1]); } -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals – www.phparch.com

« previous php.general (#190791) next »