PHP 从输出中删除硬 Return
PHP Remove Hard Return From Output
我知道有一些 post 关于这个主题。我查看了它们并尝试了代码,但它不适用于我的特定代码。有人可以帮我从输出中删除 returns 的代码吗?这是我的代码。
function random_phrase ()
{
$quotes = file ("quotes.txt");
$num = rand (0, intval (count ($quotes) / 3)) * 3;
return $quotes[$num];
}
为了调用它,我正在使用 random_phrase()
这两个都试过了:
str_replace("\n", "")
str_replace(array("\r","\n"))
也许我没有把它们放在正确的地方。
我的输出看起来像这样:
Quote 1
Quote 2
Quote 3
我想要:
Quote 1 Quote 2 Quote 3
我知道有一些 post 关于这个主题。我查看了它们并尝试了代码,但它不适用于我的特定代码。有人可以帮我从输出中删除 returns 的代码吗?这是我的代码。
function random_phrase ()
{
$quotes = file ("quotes.txt");
$num = rand (0, intval (count ($quotes) / 3)) * 3;
return $quotes[$num];
}
为了调用它,我正在使用 random_phrase()
这两个都试过了:
str_replace("\n", "")
str_replace(array("\r","\n"))
也许我没有把它们放在正确的地方。
我的输出看起来像这样:
Quote 1
Quote 2
Quote 3
我想要:
Quote 1 Quote 2 Quote 3