2011-05-02 77 views
7

我一直在做一個評論框,並在查看我的評論後出現問題。我想要的只是當我的評論自動斷線,當它超過容器,但我現在有一條直線。在HTML中自動斷行

例如:

 
tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt

我希望我的文字可以是這樣的:

 
ttttttttttttt 
ttttttttttttt 
ttttttttttttt 
ttttttttttttt 

我應該用什麼來讓我的文字自動斷線?

回答

2

嘗試使用字符串替換:

$line_broken = str_replace("\n", "<br />", $comment); 

但很難說沒有看到你的代碼。

+1

我認爲他想長字符串自動斷到新的生產線,但我可能誤會了... – Vache 2011-05-02 01:25:53

+0

我不認爲這是問題,但如果它是,有一個本地功能:http://php.net/manual/en/function.nl2br.php – thirtydot 2011-05-02 01:28:38

0

不知道如何在沒有大塊PHP的情況下自動斷行。您可以考慮使用CSS overflow: hidden;overflow: auto;作爲您的評論容器。

+0

我試圖溢出,但仍然無法正常工作。感謝您的回覆 – 2011-05-02 01:31:26