J
J
JackShcherbakov2018-02-26 23:43:49
PHP
JackShcherbakov, 2018-02-26 23:43:49

The trim() function prints the cracks. What to do?

Hello!
Here is the code:

<pre>
<?php
  $str = "Фриланс";
  print trim($str,"Фри");
?>
</pre>

Here is the result:
�анс
Here is the documentation: php.net/manual/ru/function.trim.php
How to fix it?
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
po5epT, 2018-02-26
@JackShcherbakov

How to fix?

Do not use trim for this purpose.
And look, for example, at substr, or rather at its analogue for multibyte strings mb_substr();
$str = "Фриланс";
mb_substr($str, 3, null, "UTF-8");

Result:
ланс

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question