I want to cut description string “$values[‘description’]” after 13 character and add 3 dots after.
I found a solution here:
PHP – cut a string after X characters
$string = (strlen($string) > 13) ? substr($string,0,10).'...' : $string;
But it’s a little bit complicated for me to combinate it with my code:
‘desc’ => str_replace(array(“\t”,”\r”, “\n”), ”,
preg_replace(‘/(<.*?>)/’, ”,
htmlspecialchars_decode($values[‘description’])))
Then add to your array?… leaves you with:
So the code should follow lines 1 and 2. Then $var= array(‘desc’ => $string); or whatever your trying to do.