php str_replace 输入框回车替换br

作者:袖梨 2022-06-24
 代码如下 复制代码

function htmtocode($content) {
    $content = str_replace("n", "
", str_replace(" ", " ", $content));
    return $content;
}


先替换掉空格,再替换回车。
相当于:

 代码如下 复制代码
function htmtocode($content) {
    $content = str_replace(" ", " ", $content);
    $content = str_replace("n", "
",$content);  
    return $content;
}

相关文章

精彩推荐