2010-07-13 5 views
5

Как сделать, чтобы напечатать «>» перед каждой строкой?Печать «>» на каждой строке

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.
+1

Заменить символ новой строки с символом новой строки затем '>'. Однако не уверен в специфике PHP. Надеюсь, это поможет.. –

ответ

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

использование str_getcsv или взрываются, чтобы получить линии ваш текстовый блок, а затем распечатайте каждую строку (например, вы уже сделали).

0

попробовать этот НИИЯФ

if ($quoteid) { 
    echo str_replace("\n", "\n> ", $quote['message']); 
} 
Смежные вопросы