Re: Getting substring of text for first paragraph

From: Date: Mon, 13 May 2002 03:00:37 +0000
Subject: Re: Getting substring of text for first paragraph
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-97291@lists.php.net to get a copy of this message
On Sun, 12 May 2002, Steven Jarvis wrote: > I want to do the following: > > Big chunk of text is stored in variable $a. Paragraph breaks are > signalled by two line breaks. How big is big? 100 lines? 10,000 lines? 1,000,000 lines? > I want to just extract the first paragraph (i.e., all the text up to the > first set of two line breaks) from $a. > > How would I do this? > > I tried exploding $a into an array, then doing a while loop inside a for > loop, but it was taking WAY too long to execute (it was timing out). > > Is there an easy way to do this that I'm just overlooking? The easiest would be $first_graf = substr($big_text, 0, strpos($big_text, "\n\n")); The manual is your friend. There's a function for almost anything. While you are eating your corn flakes in the morning you should be reading through them and filing them away in your brain. miguel

« previous php.general (#97291) next »