2010-07-13 37 views
5

¿Cómo debo imprimir un ">" antes de cada línea?Imprimir ">" en cada línea

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

Actualmente Parece que este:

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

quiero que se vea como esto:

> 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

Sustituir el carácter de nueva línea con una nueva línea a continuación, '>'. Sin embargo, no estoy seguro de los detalles en PHP. Espero que ayude.. –

Respuesta

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

uso str_getcsv o explotar para obtener las líneas de su bloque de texto y luego imprima cada línea (como ya lo hace).

0

tratan con str_replace

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

probar este SINP

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