Location: PHPKode > scripts > LQueryBU > LQueryBU/query_units/examples/functions/examplef1.php
====EXECPHPCODE====

<?php
// Parameteres are recived as any other sql unit, throw the parameteres array, and can be 
// used [PARAMETER1]  or  $RECORD->parameter1 , as you prefer.

// EXAMPLE OF TEXT WORD CUT
// Cuts a STRING at LCUT position, dropping last word, and adding "..." at the end. 

// Inside a Unit, in the POST_FORMAT_FIELDS, you can call this function as this:
// $RECORD->Description_wordcut = $this->getDataQuery("/functions/examplef1",array("STRING" => $RECORD->description,"LCUT" => 40));


$origText = trim("[STRING]");
$destText = $origText;
$maxLen = "[LCUT]";
$origLen = strlen($origText);

if ($origLen > $maxLen);
{
	$destText = substr($origText,0,$maxLen);
	$destText = explode(" ",$destText);
	unset($destText[count($destText)-1]);
	$destText = implode(" ",$destText)."...";
} 
return $destText;

?>
Return current item: LQueryBU