PHP中替换函数str_replace()

str_replace(find,replace,string,count)
find:需要替换的值
replace:将要替换的值,
string:被替换的字符串
count:同级替换的次数

如果需要把数据库中存储的带回车以及空格的文章,按照其原来的样式显示在html中,可以使用此函数,

function htmtocode( $content ) {
    $content = str_replace( '\n','<br/>',str_replace(' ','&nbsp;' ,$content) );
    return $content;
}

猜你喜欢

转载自www.cnblogs.com/MrBear/p/9955804.html
今日推荐