Hello, please I am trying to remove carriage return from the input of a textarea. I want to just count the words. If the words are more than 60, an error message is displayed. But the programme keeps counting the carriage returns. I want to remove the carriage returns then count the words to see if they are more than 60. I am using the following codes.
if ($_POST["description"])
{
$string = $_POST["description"];
//$string = preg_replace("/(\r\n){3,}/","",trim($text));
//$string = str_replace("\r", '', $text);
//$string = trim(preg_replace('/\s\s+/', ' ', $string));
$string = trim(preg_replace('/\s+/', ' ', $string));
$check = str_word_count($string);
if ($check > 60)
{
$brief_60_err = "<p class=\"notice\">The abstract is <span class=\"blue\">$check</span> words. Reduce it to 60 words</p>";
$send ="no";
}
}