I try to cut a string from array to a specified length with PHP
<div class="ct f-light">
$num_char = 255;
$text = $in['content'];
echo substr($text, 0, $num_char) . '...';
What does your $in['content'] look like? Is it in html? Or how did you mix images and text?
If you have that, I would suggest separating them. (into different variables) This would be the cleanest option. Alternatively, you can also search for the first image tag and then only use the text before that, like this:
$num_char = 255; $text = explode('<img', $in['content'], 2); echo substr($text, 0, $num_char) . '...';
You then might also want to check for an empty string.
If you are not using html, please clarify what you are using.
(Also, in case you didn't notice, tags like
<p> will count towards the 255 character limit, so there will most likely be less than 255 characters visible. Also this might result in bad (incomplete) html.)