打印“>”在每一行

时间:2010-07-13 12:20:13

标签: php

我该如何打印“>”在每一行之前?

if ($quoteid) {
echo ' 
> '.$quote['message'].' 
'; 
}

目前看起来像这样:

> I would move Heaven and Hell and anything in between to get to you. 
You wouldn't be safe anywhere if I was mad at you.
And that's not bull; that's truth. I've went up against people.
You could pull a gun on me and if I'm mad at you I'm coming forward.
You'd have to shoot me to stop me and if you don't kill me... you're stupid cause the next time you see me I will kill you.

我希望它看起来像这样:

> I would move Heaven and Hell and anything in between to get to you. 
> You wouldn't be safe anywhere if I was mad at you.
> And that's not bull; that's truth. I've went up against people.
> You could pull a gun on me and if I'm mad at you I'm coming forward.
> You'd have to shoot me to stop me and if you don't kill me... you're stupid cause the next time you see me I will kill you.

7 个答案:

答案 0 :(得分:10)

if ($quoteid) {
    // Replace new line with new line + "> "
    echo '>' . str_replace("\n", "\n> ", $quote['message']);
}

答案 1 :(得分:2)

if ($quoteid) { 
   echo ' > '.str_replace("\n","\n > ",$quote['message'])';  
} 

答案 2 :(得分:0)

使用str_getcsv或explode来获取文本块的行,然后打印每一行(就像你已经做过的那样)。

答案 3 :(得分:0)

尝试使用str_replace

$bodytag = str_replace("\n", ">", $quote['message']);

答案 4 :(得分:0)

echo str_replace(array("\r\n", "\n"), "\n> ", $quote['message']);

答案 5 :(得分:0)

尝试这个sinp

if ($quoteid) {
    echo str_replace("\n", "\n> ", $quote['message']);
}

答案 6 :(得分:0)

echo '>'.substr("\n", "\n>", $quote['message']);
相关问题