strrpos.php
<?php
$limit = 100;
$summary = <<< summary
this is a test. this is a test. this is a test. this is a test. this is a test. this is a test.
this is a test. this is a test. this is a test. this is a test. this is a test. this is a test.
this is a test. this is a test. this is a test. this is a test. this is a test. this is a test.
summary;
if (strlen($summary) > $limit)
$summary = substr($summary, 0, strrpos(substr($summary, 0, $limit), ' ')) . '...';
echo $summary;
?>
Related examples in the same category