Hi! Could we please enable some services and cookies to improve your experience and our website?

PHPize Online / SQLize Online  /  SQLtest Online

A A A
Login    Share code      Blog   FAQ

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

Copy Format Clear

Stuck with a problem? Got Error? Ask AI support!

Copy Clear
Copy Format Clear
<?php $description = "аа бб ввffftfftfв ггг ддfд еее жжggffж ззз иии ккк ллл ммм ннн ооо ппп ррр ссс ттт"; var_dump(mb_strlen($description)); function cutText($text, $limit, $add = "...") { $text_length = mb_strlen($text); if ($text_length <= $imit) { return $text; } $add_length = mb_strlen($add); $offset = $text_length - $limit + $add_length; $end = mb_strrpos($text, " ", -$offset); return mb_substr($text, 0, $end).$add; } $description = cutText($description, 30); var_dump($description, mb_strlen($description), $descr_offset);
Copy Clear