JuliaRietveld
3/31/2017 - 11:58 AM

Create a text snippet

Create a text snippet

function show_excerpt($text, $chars = 450 ) {
	$text = $text. " ";

	// return part of a string. 1st: which text, 2nd: start, 3rd: how many chars
	$text = substr($text, 0, $chars);

	// Don't cut off a part of a word. Find position at the beginning of a word
	$text = substr($text, strpos($text, ' '));
	$text = $text. " ... ";

	return $text;
}

////

<p><?php echo show_excerpt($row['post_body'], 200); ?></p>