PHP convert br tag to new line

By using this PHP code snippet you can convert br tag to new line character.


									<?php

function br2nl($str, $nl = "\n") {
	return preg_replace('/<br(\s+)?\/?>/i', $nl, $str);
}

// Example:
echo br2nl("hello<br/>world");
echo br2nl("<br>hello<br/>world", "\r\n");

?>
								

crypto.man

Formal education will make you a living; self-education will make you a fortune.

Comments (0)

No Comments Yet.