You have to remove all line breaks using \s
in the regular expression:
$str ="
- Capable for unlimited product
- Two currency support
- Works with touch screens and click screen based systems
- Responsive design shopping cart, Specially design for Mac, iPhone, iPad, PC and Android
- VAT for countries that support a Value Added Tax
- Barcode scanner checkout option for POS
- mRSS
";
preg_match("/^([A-Za-z0-9\s\<\>\.\,\/\-\ ]+)$/", $str);
// Sanitize your code before save to database.
function test_input($data) {
$data = trim($data);
$data = htmlspecialchars($data);
$data = json_encode($data);
$data = addslashes($data);
return $data;
}
echo test_input($str);