我有以下存儲在數據庫中精確的字符串:如何在PHP中保留前端的額外空間?
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
注意額外的空間和額外的段落/換行符我在字符串中增加了。
在PHP我顯示使用echo nl2br($val);
那麼它保留了一段換行,但刪除字符串中給出的額外空間這個數據。
我怎樣才能解決這個問題,請大家幫忙!
請參閱:http:// stackoverflow。com/q/2300142/3933332 – Rizier123
對[tag:html]而言,這實際上比[tag:php]要多得多...... – deceze
真正的問題是爲什麼你想要這樣做 - 如果你想要格式化文本通過放入大量空格,那麼你做錯了。由於HTML和CSS都提供了所有格式化功能,因此很少有很好的理由嘗試使用空格字符。你給出的例子顯然不是你想要達到的目標的準確表示,所以我很難進一步說出你應該怎麼做,但空間不是答案。 – Simba