Message Preview

Started on the old forum in November 2009 · view the original in the archive · old links redirect here

5 replies · 515 views · started 17 years ago · 1 min read

3 participants
Pablo Developer · 164 posts #1

hey i see this code alot a places and i think its kool but i cant seem to get it

when u get a new PM and it looks like this

$user $pmpreview username hi there.....

any one can help me wit this?

Loony Senior · 258 posts #5
function word_limiter($str, $n = 10, $end_char = '…')
{
	if (strlen($str) < $n)
	{
		return $str;
	}
	
	$words = explode(' ', preg_replace("/\s+/", ' ', preg_replace("/(\r\n|\r|\n)/", " ", $str)));
	
	if (count($words) <= $n)
	{
		return $str;
	}
			
	$str = '';
	for ($i = 0; $i < $n; $i++)
	{
		$str .= $words[$i].' ';
	}

	return trim($str).$end_char;
}

will return 10 words as well

Creator of Epix.Mobi

Keep an Eye on us Big things coming soon!!!! Need something for your site hit me up here http://coding-talk.com/forum/main-forums/marketplace/153110-free-features-for-your-wapsite

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close