M
M
marq2021-08-14 17:46:32
PHP
marq, 2021-08-14 17:46:32

Does a black question mark appear at the end when cropping text from a database?

I output only the first 40 characters from the database and replace the rest with ellipsis, but at the end a question mark appears.

$str = $key['post_text'];
         if (strlen($str) > 40) $str = substr($str, 0, 40) . '...';
cut like this

despite the fact that I can.. - Ruzltat

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Ukolov, 2021-08-14
@marq

mb_strlen and mb_substr.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question