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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.