好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

php str_replace 输入框回车替换br - php函数

php str_replace 输入框回车替换br

在我们用textarea时会发现回车与空格是不可看到的,所以我们利用str_replace函数将php中的\\n替换成br就可以了,有需要的朋友可以参考,代码如下:

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

先替换掉空格,再替换回车,相当于如下代码:

function  htmtocode( $content ) {       $content  =  str_replace ( " " ,  " " ,  $content );       $content  =  str_replace ( "n" ,  "<br>" , $content );          return   $content ;       //开源代码phpfensi测试数据   }

查看更多关于php str_replace 输入框回车替换br - php函数的详细内容...

  阅读:40次