Hi! Could we please enable some services and cookies to improve your experience and our website?
Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code
<?php
$description = "аа бб ввffffffв ггг ддfд еее жжggffж ззз иии ккк ллл ммм ннн ооо ппп ррр ссс ттт";
var_dump(mb_strlen($description));
$descr_limit = 40;
$descr_len = mb_strlen($description);
if ($descr_len > $descr_limit) {
$descr_offset = $descr_len - $descr_limit + 3;
$description = mb_substr($description, 0, mb_strrpos($description, " ", -$descr_offset));
$description .= "...";
}
var_dump($description, mb_strlen($description), $descr_offset);