분류 php

BR -> 새라인으로 변환

컨텐츠 정보

  • 조회 1,635 (작성일 )

본문

BR태그를 새라인으로 변환하는 방법들입니다.

 

1. 

function br2newline( $input ) {

     $out = str_replace( "<br>", "\n", $input );

     $out = str_replace( "<br/>", "\n", $out );

     $out = str_replace( "<br />", "\n", $out );

     $out = str_replace( "<BR>", "\n", $out );

     $out = str_replace( "<BR/>", "\n", $out );

     $out = str_replace( "<BR />", "\n", $out );

     return $out;

 

2.

function br2nl( $input ) {

 return preg_replace('/<br(\s+)?\/?>/i', "\n", $input);

}

 

3.

function _br2nl($input)

{

return str_replace(array(“<br>”, “<BR>”, “<br/>”, “<BR/>”, “<br />”, “<BR />”),”\n”, $input );

 

4. 

function _br2nl($input)

{

return str_replace(array('', '', ''),'\n', strtolower($input) );

}

 

php