RE: [PHP] summarized results w/function

From: Date: Wed, 25 Aug 2004 19:46:14 +0000
Subject: RE: [PHP] summarized results w/function
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-194722@lists.php.net to get a copy of this message
Anything can be used, I was using that as an example. The information in the database contains html elements that were passed through a form. For example a user would type in <b>some</b> and then the mysql field would contain <b>some</b>. -----Original Message----- From: John Holmes [mailto:holmes072000@charter.net] Sent: Wednesday, August 25, 2004 2:42 PM To: Erik Meyer; Php-General Subject: Re: [PHP] summarized results w/function From: "Erik Meyer" <emeyer@ebaseweb.com> > Here is function > > function shorten_news_results ($input_text, $ending_text) { > $news_strip=str_word_count($input_text, 1); > $news_split=array_splice($news_strip, 0, 40); > $news_split[]=$ending_text; > $news_story=implode(' ', $news_split); > echo "$news_story"; > } Trying to split a string down the middle and not break up any kind of HTML that's present is difficult without looping through each character and keeping track of whether you're in an HTML element or not. Your original messages says <b> can be used. Is that the only tag? Is it a limited set of HTML or can anything be in the text? ---John Holmes...

« previous php.general (#194722) next »