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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php