我需要知道如何使用 PHP 查找字符串中特殊字符的出现次数
这是代码...
<?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;
?>