S
S
s4rcasm3222017-04-03 00:20:50
PHP
s4rcasm322, 2017-04-03 00:20:50

How can I correctly display Cyrillic in PHP?

In the function, the input parameter is Russian characters from POST, how can I display them correctly? Tried mb_convert_encoding - doesn't work5873372afcf84c18861d6824ad37a3f1.png

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Andrew, 2017-04-03
@R0dger

look towards iconv

E
exactly the most, 2017-04-03
@dalmariko

function str_split_unicode($str, $l = 0) {
    if ($l > 0) {
        $ret = array();
        $len = mb_strlen($str, "UTF-8");
        for ($i = 0; $i <= $len; $i += $l) {
            $ret[] = mb_substr($str, $i, $l, "UTF-8");
        }
        return $ret;
    }
    return preg_split("//u", $str, -1, PREG_SPLIT_NO_EMPTY);
}

V
Vitaly Sorokin, 2017-04-03
@SorokinWS

If the server is Apache (and most often it is), add the line AddDefaultCharset UTF-8 to .htaccess

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question