什么语言是 ?-我需要将空间转换为它的&;nbsp;equivalent


What language are ? - I need to convert the space to its   eqivalent

我需要将所有新行、回车和空格转换为HTML标记。我正在使用字符串替换将'n替换为<br />,并且至少需要找到一种转换空格的方法。

nl2br()适用于<br />的换行符,但要做到这一切,您仍然使用str_replace():

$result = str_replace(array(" ","'n","'r"), array("&nbsp;","<br />",""), $string);