The easiest way to do this is with substr. I'm surprised you didn't think of it since you're using utf8_substr
, which appears to do the same thing.
$descr = ($option_count > 0 ? ', ' : '') . $option['name'] . ':' . (utf8_strlen($value) > 20 ? utf8_substr($value, 0, 20) . '..' : $value);
$descr = substr($descr, 0, 126);
$data['L_PAYMENTREQUEST_0_DESC' . $i] = $descr;