I need to parse a string and replace newline characters (either '\n' or'\r') with <p> tags.
Is preg_replace() the best function to use for this?
If there are two or more newline tags together, they must only produce one <p> tag. So if the string contained '\n\n\n' or '\r\r\r' or '\n\r', I'd need to replace it with a single <p>.
Could anyone help me out with the syntax please?
Is preg_replace() the best function to use for this?
If there are two or more newline tags together, they must only produce one <p> tag. So if the string contained '\n\n\n' or '\r\r\r' or '\n\r', I'd need to replace it with a single <p>.
Could anyone help me out with the syntax please?