glennda Posted February 11, 2011 Posted February 11, 2011 I have a form that is submitting for the noticeboard I have made - Edu-it has pointed out it doesn't do lines very well! as the text area is submitting to the database as simple text. Is there a way I can convert the text from the text area into HTML before submitting to the database? Or even as it echos the content of the database convert the text into HTML? Toby
webman Posted February 11, 2011 Posted February 11, 2011 PHP function nl2br will convert new lines in plain text to HTML tags 1
glennda Posted February 11, 2011 Author Posted February 11, 2011 Webman to the rescue. Cheers. - also what can i use to convert the text which has http:// infront - I'm guessing it needs some processing to covert the link address to html?
webman Posted February 11, 2011 Posted February 11, 2011 Use a regular expression $text = preg_replace('@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@', '$1', $text); Source: http://snipplr.com/view/2371/regex-regular-expression-to-match-a-url/ 1
glennda Posted February 11, 2011 Author Posted February 11, 2011 Do you know a way to change it for if staff just post Google rather then Google I tried $text = preg_replace('@(wwww([.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@', '$1', $text); But that didn't quite work!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now