2010-07-13 6 views
5

Comment faire pour imprimer un ">" avant chaque ligne?Imprimer ">" sur chaque ligne

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

Actuellement, il se présente comme suit:

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

Je veux qu'il ressemble à ceci:

> 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

Remplacer le caractère de nouvelle ligne avec un saut de ligne, puis '>'. Je ne suis pas sûr des spécificités de PHP. J'espère que cela pourra aider.. –

Répondre

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

utilisation str_getcsv ou exploser pour obtenir les lignes de votre bloc de texte, puis imprimez chaque ligne (comme vous le faites déjà).

0

essayer avec str_replace

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

essayer PCIS

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