My son seems very interested.
Do you know why my game started?
上面是一个字符串行,我试图将其形成为
My son seems very interested. Do you know why my game started?
我尝试了以下代码
$finish_loop = "no";
while($finish_loop=="no")
{
if(!strstr($dialogue," "))
{$finish_loop = "yes";}
$dialogue = str_replace(" "," ",$dialogue);
}
但$对话仍然将$对话作为2行返回,我只想要一行中的所有内容,我如何用php实现这一点
答案 0 :(得分:0)
用空格替换文本中的新行,然后修剪它以删除superflus空格:
$dialogue = str_replace("\n\r"," ",$dialogue);
$dialogue = str_replace("\r"," ",$dialogue);
$dialogue = trim(str_replace("\n"," ",$dialogue));