小编Moh*_*fey的帖子

substr与日语字符问题

我很好地回应日语字符,但是当我尝试将字符串中的部分字符串消除时,它只是转向问号

注意:我将标题设置为utf-8

header('Content-Type: text/html; charset=utf-8');
Run Code Online (Sandbox Code Playgroud)

并做了元 <meta http-equiv="Content-type" content="text/html; charset=utf-8" />

$word = "????";
echo $word;       //works just fine

echo substr($word,-1);    //now it just echoes ?

//this one also failed
echo $word[0];    //echoes ?
Run Code Online (Sandbox Code Playgroud)

php utf-8 character-encoding

10
推荐指数
1
解决办法
2834
查看次数

在php中替换多个\ r \n

我有这样的文字:

some text \r\n \r\n\r\n\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n some text \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n some text \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n

我要更换多的每块\r\n只有一个<br/>

我尝试过使用str_replace('\\r\\n','<br/>',$text);但最终结果太多了<br/>

我需要最终输出如下:

some text <br/> some text <br/> some text <br/>

php regex string

2
推荐指数
1
解决办法
406
查看次数

标签 统计

php ×2

character-encoding ×1

regex ×1

string ×1

utf-8 ×1