I need to know how to find the number of occurrences of special characters in a string using PHP
Here is the code...
<?php
$message=$_POST['Message'];
//$rep=preg_replace("@ # $ % ^ & / . * @"," ",$message);
//$rep=preg_replace('/[^a-zA-Z0-9_ %\[\]\.\(\)%&-]/s', '', $message);
$rep = preg_replace("/[^a-zA-Z]+/", "", $message);
echo "There are ".str_word_count($message)." words found in the given message"."<br/>";
$len=strlen($rep);
echo "length of the message is ".$len;
$delims="?#";
$word = strtok($message, $delims);
echo "delim ".$word."<br/>";
echo $delimlen=strlen($word)."<br/>";
echo "without special ".$rep;
?>