当前位置:网站首页>PHP \ newline cannot be output

PHP \ newline cannot be output

2022-07-07 10:33:00 zhang-php

From the interface json Array , There is a newline in the text part of the array , use json_decode turn php After array , Output in html The page didn't wrap , At first, I thought that the newline symbol was deleted after the array was converted , Later, I tried various methods to replace characters , Finally, we found one CSS style :

white-space Property specifies how whitespace within an element is handled , The default value is normal( Blank will be ignored by browser )

Property value

value describe
normal Default . Blank will be ignored by browser .
pre Blank space will be reserved by browser . It behaves in a similar way HTML Medium <pre> label .
nowrap Text does not wrap , The text will continue on the same line , Until I met <br> Label until .
pre-wrap Keep blank sequence , But wrap normally .
pre-line Merge whitespace sequence , But keep line breaks .
inherit Rules should be inherited from the parent element white-space The value of the property .
<td style="white-space:pre-wrap">{$vo.content}</td>

After adding this attribute, the line will wrap automatically  

 

原网站

版权声明
本文为[zhang-php]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207070813302616.html