note 69823 deleted from function.strpos by bobby
| From: | bobby@php.net | Date: | Fri, 22 Sep 2006 14:45:02 +0000 |
| Subject: | note 69823 deleted from function.strpos by bobby | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-117430@lists.php.net to get a copy of this message | ||
Note Submitter: webmaster at matericosweb dot com
----
By Jaxolotl Design
This Simple function allows you to reduce a long text to an smaller one,
for example when you use articles text previews.
The cool feature is that it doesn't cuts the words,
just search for the first white space after the assigned limit and cuts the phrase there.
The Strip_tags() is used to prevent tables or any other tag to be cut unproperly.
Enjoy :)
function reduce_text($string){
//Search the end of a word after [, int offset] and set the result as limit
$limit = strpos(strip_tags($string), " ",200);
//Change this number as you need
//Use $limit to replace width ...Text
return substr_replace(strip_tags($string), " ... <em>continue</em>",$limit);
//Change "<em>continue</em>" whith anithing you want
}