Jump to content

Allowing new lines within comments


MemphiS

Recommended Posts

  • 2 weeks later...

First off I hope you have solved your problem by now, but if you haven't I would suggest that you use regular expression to validate your user input since it is as configurable as anything gets...

 

<?php

$user_input = "Text of line one\ntext of line two\ntext of line three";

if(preg_match("/^[a-z0-9\s]+$/",$user_input)){
  echo "User input is valid";
}
else{
  echo "User input not valid";
}
?>

 

The above code checks if the user input consists of letters a-z, digits 0-9 and whitespace which includes tabs, spaces and line breaks.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.