Algorithms
|
|
|
|
<?php
/*
kriek at phpfreaks dot com
Keep this block intact please
*/
function chopSent($varb, $num) {
$dNum = intval($num);
if (strlen($varb) > $dNum) {
$nVarb = substr($varb, 0, $dNum);
$nVarb .= '...';
}
elseif(strlen($varb) < $dNum) {
$nVarb = $varb;
}
return $nVarb;
}
// Usage of function
$theSent = 'PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML';
$theSent = chopSent($theSent, 55);
echo $theSent; ?>
|
|
|
Usage Example
|
|
|
Rate This Script
|
|
|
|