Following function will crop a string and also append three dots to string.
$char variable indicates the length.
$stringsvariable indicates the string.
For Example :
$strings = "I am a TYPO3 & PHP Developer"; $chars = 6;
Below function is for PI base. Will work till TYPO3 4.7.XX Version.
$data = t3lib_div::fixed_lgd_cs($strings,$chars); echo $data;
Output Will be :
I am a...
It will automatically append three dots at end of the string.
if we use negative number then it will crop that amount of character at end of the string.
$chars = -9;
Then output Will be :
It will automatically append three dots at beginning of the string.
Above script will work for PI base only.
If you want to set this function in ext base fluid then simple you have to use “\TYPO3\CMS\Core\Utility\GeneralUtility” instead of “t3lib_div“.
Following function will work for TYPO3 6.x.xx
$data = \TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($strings,$chars);
I hope it will work for you 🙂
If you have any queries, please do not hesitate to contact me at Jainish Senjaliya