S
S
Sergey2015-12-17 21:03:49
PHP
Sergey, 2015-12-17 21:03:49

Seems like a commonplace problem with substr and mb_substr?

There is a site on Joomla, in one module you need to limit the output of the header
. This code inserts diamonds with questions, they say you need to use mb_substr:

if (strlen($item->title) > 70) {
  $item->title = substr($item->title, 0, 70);
}

Doesn't cut string:
$item->title = mb_substr($item->title, 0, 70);
Returns false:
strlen($item->title)
Doesn't solve problems:
mb_internal_encoding("UTF-8");
ms_string is enabled joxi.ru/5mdQp09Ivkqan2

Answer the question

In order to leave comments, you need to log in

5 answer(s)
A
Alexander Aksentiev, 2015-12-17
@Sanasol

mb_substr needs to be told which encoding to cut.
and also use not strlen, but mb_strlen and also specifying the encoding

S
Sergey, 2015-12-18
@gangstarcj

I wrote to the hoster, they did something and it worked

N
Neutro, 2014-05-02
@tsisforever

This is a template engine, of which there are a great many. For example, in FatFree it will look like in {{ @имя_переменной }}Multilingual style, then it is very easy to add something in style {{ @current_lang['Phrase_A'] }}or {{ @langGet('Phrase_A') }}As I said there are a lot of templating engines, find the one that you like best.

A
Artyom Luchnikov, 2014-05-01
@lu4nik

Perhaps it means outputting a string through echo.
If a string is displayed in double quotes, then variables can be used inside, for example
If the interpreter encounters a $ sign, it captures as many characters as possible to form a valid variable name. If you want to specify the end of a name, enclose the variable name in curly braces.

echo "пример {$str}s"; //будет использована переменная $str

T
trall, 2014-05-01
@sashablashenkov

This is most likely a template, and then it is replaced with str_replace (), but multilingualism cannot be added there (sort of)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question